Java Code Examples for android.widget.ListView#addHeaderView()

The following examples show how to use android.widget.ListView#addHeaderView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlacePickerFragment.java    From android-skeleton-project with MIT License 8 votes vote down vote up
@Override
void setupViews(ViewGroup view) {
    if (showSearchBox) {
        ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);

        View searchHeaderView = getActivity().getLayoutInflater().inflate(
                R.layout.com_facebook_picker_search_box, listView, false);

        listView.addHeaderView(searchHeaderView, null, false);

        searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text);

        searchBox.addTextChangedListener(new SearchTextWatcher());
        if (!TextUtils.isEmpty(searchText)) {
            searchBox.setText(searchText);
        }
    }
}
 
Example 2
Source File: ConversationListView.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public void initModule() {
    mConvListView = (ListView) mConvListFragment.findViewById(R.id.conv_list_view);
    mCreateGroup = (ImageButton) mConvListFragment.findViewById(R.id.create_group_btn);
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mHeader = (LinearLayout) inflater.inflate(R.layout.conv_list_head_view, mConvListView, false);
    mSearchHead = (LinearLayout) inflater.inflate(R.layout.conversation_head_view, mConvListView, false);
    mLoadingHeader = (RelativeLayout) inflater.inflate(R.layout.jmui_drop_down_list_header, mConvListView, false);
    mLoadingIv = (ImageView) mLoadingHeader.findViewById(R.id.jmui_loading_img);
    mLoadingTv = (LinearLayout) mLoadingHeader.findViewById(R.id.loading_view);
    mSearch = (LinearLayout) mSearchHead.findViewById(R.id.search_title);
    mNull_conversation = (TextView) mConvListFragment.findViewById(R.id.null_conversation);
    mAllUnReadMsg = (TextView) mFragment.getActivity().findViewById(R.id.all_unread_number);
    mConvListView.addHeaderView(mLoadingHeader);
    mConvListView.addHeaderView(mSearchHead);
    mConvListView.addHeaderView(mHeader);
}
 
Example 3
Source File: PlacePickerFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
void setupViews(ViewGroup view) {
    if (showSearchBox) {
        ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);

        View searchHeaderView = getActivity().getLayoutInflater().inflate(
                R.layout.com_facebook_picker_search_box, listView, false);

        listView.addHeaderView(searchHeaderView, null, false);

        searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text);

        searchBox.addTextChangedListener(new SearchTextWatcher());
        if (!TextUtils.isEmpty(searchText)) {
            searchBox.setText(searchText);
        }
    }
}
 
Example 4
Source File: FadingActionBarHelperBase.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private View createListView(ListView listView) {
    ViewGroup contentContainer = (ViewGroup) mInflater.inflate(R.layout.fab__listview_container, null);
    contentContainer.addView(mContentView);

    mHeaderContainer = (FrameLayout) contentContainer.findViewById(R.id.fab__header_container);
    initializeGradient(mHeaderContainer);
    mHeaderContainer.addView(mHeaderView, 0);

    mMarginView = new FrameLayout(listView.getContext());
    mMarginView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, 0));
    listView.addHeaderView(mMarginView, null, false);

    // Make the background as high as the screen so that it fills regardless of the amount of scroll. 
    mListViewBackgroundView = contentContainer.findViewById(R.id.fab__listview_background);
    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams();
    params.height = Utils.getDisplayHeight(listView.getContext());
    mListViewBackgroundView.setLayoutParams(params);

    listView.setOnScrollListener(mOnScrollListener);
    return contentContainer;
}
 
Example 5
Source File: PullToRefreshListView.java    From letv with Apache License 2.0 6 votes vote down vote up
protected final ListView createRefreshableView(Context context, AttributeSet attrs) {
    ListView lv = new InternalListView(this, context, attrs);
    lv.setLayoutParams(new LayoutParams(-1, -1));
    int mode = getMode();
    String pullLabel = context.getString(2131100695);
    String refreshingLabel = context.getString(2131100699);
    String releaseLabel = context.getString(2131100700);
    if (mode == 1 || mode == 3) {
        FrameLayout frame = new FrameLayout(context);
        this.mHeaderLoadingView = new PullToRefreshHeaderView(context, 1, releaseLabel, pullLabel, refreshingLabel, this.objs);
        frame.addView(this.mHeaderLoadingView, -1, -2);
        this.mHeaderLoadingView.setVisibility(8);
        lv.addHeaderView(frame, null, false);
    }
    if (mode == 2 || mode == 3) {
        this.mLvFooterLoadingFrame = new FrameLayout(context);
        this.mFooterLoadingView = new PullToRefreshHeaderView(context, 2, releaseLabel, pullLabel, refreshingLabel, this.objs);
        this.mLvFooterLoadingFrame.addView(this.mFooterLoadingView, -1, -2);
        this.mFooterLoadingView.setVisibility(8);
    }
    lv.setId(16908298);
    return lv;
}
 
Example 6
Source File: PlacePickerFragment.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@Override
void setupViews(ViewGroup view) {
    if (showSearchBox) {
        ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);

        View searchHeaderView = getActivity().getLayoutInflater().inflate(
                R.layout.com_facebook_picker_search_box, listView, false);

        listView.addHeaderView(searchHeaderView, null, false);

        searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text);

        searchBox.addTextChangedListener(new SearchTextWatcher());
        if (!TextUtils.isEmpty(searchText)) {
            searchBox.setText(searchText);
        }
    }
}
 
Example 7
Source File: HeaderAdViewView.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Override
protected void getView(List<String> list, ListView listView) {
    View view = mInflate.inflate(R.layout.header_ad_layout, listView, false);
    ButterKnife.bind(this, view);

    dealWithTheView(list);
    listView.addHeaderView(view);
}
 
Example 8
Source File: NavigationDrawerFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    mDrawerListView = (ListView) inflater.inflate(
            R.layout.fragment_navigation_drawer, container, false);
    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
        }
    });

    mValues = new DrawerOption[]{
            new DrawerOption(getString(R.string.title_section1),R.drawable.orders,0),
            new DrawerOption(getString(R.string.title_section2),R.drawable.products,0),
            new DrawerOption(getString(R.string.title_section3),R.drawable.customers,0),
            //new DrawerOption(getString(R.string.title_section4),R.drawable.logo,0),
            new DrawerOption(getString(R.string.title_section5),R.drawable.logout,-1)
    };
    mAdapter = new DrawerAdapter(getActionBar().getThemedContext(),mValues);
    mDrawerListView.setAdapter(mAdapter);

    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);

    View header = inflater.inflate(R.layout.fragment_navigation_drawer_header, container, false);
    mDrawerListView.addHeaderView(header);

    getActivity().getSupportLoaderManager().initLoader(SHOP_LOADER, null, this);

    return mDrawerListView;
}
 
Example 9
Source File: HeaderFilterViewView.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Override
protected void getView(Object obj, ListView listView) {
    View view = mInflate.inflate(R.layout.header_filter_layout, listView, false);
    ButterKnife.bind(this, view);

    dealWithTheView(obj);
    listView.addHeaderView(view);
}
 
Example 10
Source File: AboutFragment.java    From NetEasyNews with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initView() {
    data = getActivity().getResources().getStringArray(R.array.array_about_type);
    mListView = (ListView) mView.findViewById(R.id.list_item);

    View user_view = LayoutInflater.from(getActivity()).inflate(R.layout.user_view, mListView, false);
    ImageView user_icon = (ImageView) user_view.findViewById(R.id.user_icon);
    TextView user_name = (TextView) user_view.findViewById(R.id.user_name);

    mListView.addHeaderView(user_view);

}
 
Example 11
Source File: AppDetail.java    From Notification-Analyser with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_detail);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    parseAdditionalData();

    ListView list = (ListView) findViewById(R.id.list_notification_items);
    list.addHeaderView(makeListHeader(), null, false);
    list.setAdapter(new NotificationItemAdapter(this, makeListObjects()));
}
 
Example 12
Source File: HeaderChannelViewView.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Override
protected void getView(List<ChannelEntity> list, ListView listView) {
    View view = mInflate.inflate(R.layout.header_channel_layout, listView, false);
    ButterKnife.bind(this, view);

    dealWithTheView(list);
    listView.addHeaderView(view);
}
 
Example 13
Source File: AppListFragment.java    From effective_android_sample with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    PackageManager packageManager = getActivity().getPackageManager();
    List<PackageInfo> packageInfoList = packageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES);

    CardListAdapter adapter = new CardListAdapter(getActivity());

    if (packageInfoList != null) {
        for (PackageInfo info : packageInfoList) {
            adapter.add(info);
        }
    }

    int padding = (int) (getResources().getDisplayMetrics().density * 8); // 8dip
    ListView listView = getListView();
    listView.setPadding(padding, 0, padding, 0);
    listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
    listView.setDivider(null);

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View header = inflater.inflate(R.layout.list_header_footer, listView, false);
    View footer = inflater.inflate(R.layout.list_header_footer, listView, false);
    listView.addHeaderView(header, null, false);
    listView.addFooterView(footer, null, false);

    setListAdapter(adapter);
}
 
Example 14
Source File: SearchBookContentsActivity.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
Example 15
Source File: WebAndListActivity.java    From PairScrollView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_and_list);

    final WebView webView = (WebView) findViewById(R.id.web);

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return super.shouldOverrideUrlLoading(view, url);
        }
    });
    webView.loadUrl("http://www.angeldevil.me");
    // webView.loadData("Test</br>Test</br>Test</br>Test</br>Test</br>Test", "text/html", "utf-8");

    final ListView list = (ListView) findViewById(R.id.list);
    int count = 40;
    ArrayList<String> data = new ArrayList<String>(count);
    for (int i = 0; i < count; i++) {
        data.add("Text " + i);
    }
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_expandable_list_item_1, data);
    TextView header = new TextView(this);
    header.setText("Header");
    list.addHeaderView(header);
    list.setAdapter(adapter);
    
}
 
Example 16
Source File: NavigationDrawerFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    mDrawerListView = (ListView) inflater.inflate(
            R.layout.fragment_navigation_drawer, container, false);
    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
        }
    });

    mValues = new DrawerOption[]{
            new DrawerOption(getString(R.string.title_section1),R.drawable.orders,0),
            new DrawerOption(getString(R.string.title_section2),R.drawable.products,0),
            new DrawerOption(getString(R.string.title_section3),R.drawable.customers,0),
            //new DrawerOption(getString(R.string.title_section4),R.drawable.logo,0),
            new DrawerOption(getString(R.string.title_section5),R.drawable.logout,-1)
    };
    mAdapter = new DrawerAdapter(getActionBar().getThemedContext(),mValues);
    mDrawerListView.setAdapter(mAdapter);

    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);

    View header = inflater.inflate(R.layout.fragment_navigation_drawer_header, container, false);
    mDrawerListView.addHeaderView(header);

    getActivity().getSupportLoaderManager().initLoader(SHOP_LOADER, null, this);

    return mDrawerListView;
}
 
Example 17
Source File: AddItemShoppingList.java    From ShoppingList with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_add_item_shopping_list);

	try {
		shoppingList = ShoppingListDAO.select(this, getIntent().getExtras().getInt((getString(R.string.id_shopping_list))));
	} catch (VansException e) {
		Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
		e.printStackTrace();
	}

	this.setTitle(shoppingList.getName());

	lvItensShoppingList = (ListView) findViewById(R.id.lvItemShoppingList);
	lvItensShoppingList.setOnItemClickListener(this);
	lvItensShoppingList.setOnItemLongClickListener(this);

	headerView = (View) getLayoutInflater().inflate(R.layout.header_list_view_item_shopping_list, null);
	lvItensShoppingList.addHeaderView(headerView, null, false);

	adapter = new ItemShoppingListCursorAdapter(this, shoppingList.getId());
	lvItensShoppingList.setAdapter(adapter);

	edUnitValue = (EditText) findViewById(R.id.edUnitValue);
	edUnitValue.setVisibility(UserPreferences.getShowUnitValue(this) ? View.VISIBLE : View.GONE);
	edUnitValue.setOnKeyListener(this);
	edUnitValue.addTextChangedListener(new CustomEditTextWatcher(edUnitValue, 5));
	edUnitValue.setOnFocusChangeListener(this);

	edQuantity = (EditText) findViewById(R.id.edQuantity);
	edQuantity.addTextChangedListener(new CustomEditTextWatcher(edQuantity, 4));
	edQuantity.setVisibility(UserPreferences.getShowQuantity(this) ? View.VISIBLE : View.GONE);
	edQuantity.setOnFocusChangeListener(this);

	edDescription = (AutoCompleteTextView) findViewById(R.id.edDescription);
	edDescription.setOnItemClickListener(this);
	edDescription.addTextChangedListener(new CustomEditTextWatcher(edDescription, -1));

	if ((!UserPreferences.getShowQuantity(this)) && (!UserPreferences.getShowUnitValue(this))) {
		edDescription.setImeOptions(EditorInfo.IME_ACTION_GO);
		edDescription.setOnKeyListener(this);
	} else if (!UserPreferences.getShowUnitValue(this)) {
		edQuantity.setImeOptions(EditorInfo.IME_ACTION_GO);
		edQuantity.setOnKeyListener(this);
	}

}
 
Example 18
Source File: BaseFragment.java    From UltimateRecyclerView with Apache License 2.0 4 votes vote down vote up
protected void setDummyDataWithHeader(ListView listView, View headerView) {
    listView.addHeaderView(headerView);
    setDummyData(listView);
}
 
Example 19
Source File: SearchBookContentsActivity.java    From reacteu-app with MIT License 4 votes vote down vote up
@Override
 public void onCreate(Bundle icicle) {
   super.onCreate(icicle);

fakeR = new FakeR(this);

   // Make sure that expired cookies are removed on launch.
   CookieSyncManager.createInstance(this);
   CookieManager.getInstance().removeExpiredCookie();

   Intent intent = getIntent();
   if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
     finish();
     return;
   }

   isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
   if (LocaleManager.isBookSearchUrl(isbn)) {
     setTitle(getString(fakeR.getId("string", "sbc_name")));
   } else {
     setTitle(getString(fakeR.getId("string", "sbc_name")) + ": ISBN " + isbn);
   }

   setContentView(fakeR.getId("layout", "search_book_contents"));
   queryTextView = (EditText) findViewById(fakeR.getId("id", "query_text_view"));

   String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
   if (initialQuery != null && initialQuery.length() > 0) {
     // Populate the search box but don't trigger the search
     queryTextView.setText(initialQuery);
   }
   queryTextView.setOnKeyListener(keyListener);

   queryButton = (Button) findViewById(fakeR.getId("id", "query_button"));
   queryButton.setOnClickListener(buttonListener);

   resultListView = (ListView) findViewById(fakeR.getId("id", "result_list_view"));
   LayoutInflater factory = LayoutInflater.from(this);
   headerView = (TextView) factory.inflate(fakeR.getId("layout", "search_book_contents_header"),
       resultListView, false);
   resultListView.addHeaderView(headerView);
 }
 
Example 20
Source File: BaseActivity.java    From UltimateRecyclerView with Apache License 2.0 4 votes vote down vote up
protected void setDummyDataWithHeader(ListView listView, View headerView, int num) {
    listView.addHeaderView(headerView);
    setDummyData(listView, num);
}