Java Code Examples for android.widget.ListView.getHeaderViewsCount()

The following are Jave code examples for showing how to use getHeaderViewsCount() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: decoy   File: ListViewUtil.java   View Source Code Vote up 6 votes
public static Object getViewHolderByIndex(ListView listView, int index) {
	int firstVisibleFeedPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount();
	int lastVisibleFeedPosition = listView.getLastVisiblePosition() - listView.getHeaderViewsCount();

	//只有获取可见区域的
	if (index >= firstVisibleFeedPosition && index <= lastVisibleFeedPosition) {
		View view = listView.getChildAt(index - firstVisibleFeedPosition);
		Object tag = view.getTag();
		return tag;
	} else {
		return null;
	}
}
 
Example 2
Project: StickyNavigationBar   File: MainActivity.java   View Source Code Vote up 5 votes
private void initView() {
    mListView = (ListView) findViewById(R.id.list_view);
    stickyNavHostRoot = (StickyNavHost) findViewById(R.id.sticky_nav_layout);
    stickyNavHostRoot.setVisibility(View.INVISIBLE);

    View testHeaderView = LayoutInflater.from(this).inflate(R.layout.listview_head_view_test_layout, null);
    mListView.addHeaderView(testHeaderView);

    View inflateView = LayoutInflater.from(this).inflate(R.layout.sticky_nav_host_layout, null);
    stickyNavHostHead = (StickyNavHost) inflateView.findViewById(R.id.sticky_nav_layout);
    stickyNavHostHead.setVisibility(View.VISIBLE);
    mListView.addHeaderView(stickyNavHostHead);
    STICKY_POSITION_IN_HEADER = mListView.getHeaderViewsCount();
}
 
Example 3
Project: orgzly-android   File: BookFragment.java   View Source Code Vote up 5 votes
@Override
public void onListItemClick(ListView listView, View view, int position, long id) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, listView, view, position, id);

    if ((position+1) > listView.getHeaderViewsCount()) { /* Not a header. */
        listener.onNoteClick(this, view, position, id, id);

    } else {
        if (mBook != null) {
            listener.onBookPrefaceEditRequest(mBook);
        } else {
            Log.e(TAG, "Book null on preface edit request");
        }
    }
}