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

The following examples show how to use android.widget.ListView#getHeaderViewsCount() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: faceswap   File: FilePickerActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        if (l.getHeaderViewsCount() != 1) {
            //adjust for list view header view.
            position += 1;
        }
        if (position > 0) {
            currentFile = files[position - 1];
        }
        if (adapter.getSelectedPosition() == position) {
//            hideButtons();
            adapter.setSelectedPosition(-1);
        } else {
            adapter.setSelectedPosition(position - 1);
            showButtons();
        }
        if (currentFile.isDirectory()){
            openDirectory();
        }
    }
 
Example 2
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    if (l.getHeaderViewsCount() != 1) {
        //adjust for list view header view.
        position += 1;
    }
    if (position > 0) {
        currentFile = files[position - 1];
    }
    if (adapter.getSelectedPosition() == position) {
        hideButtons();
        adapter.setSelectedPosition(-1);
    } else {
        adapter.setSelectedPosition(position - 1);
        showButtons();
    }
}
 
Example 3
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 4
Source Project: NIM_Android_UIKit   File: ListViewUtil.java    License: MIT License 5 votes vote down vote up
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 5
private int correctPositionAccountingForHeader(AdapterView<?> adapterView, int position) {
    ListView listView = (adapterView instanceof ListView) ? (ListView) adapterView : null;
    int headersCount = listView == null ? 0 : listView.getHeaderViewsCount();
    if (headersCount > 0) {
        position -= listView.getHeaderViewsCount();
    }
    return position;
}
 
Example 6
private int correctPositionAccountingForHeader(AdapterView<?> adapterView, int position) {
    ListView listView = (adapterView instanceof ListView) ? (ListView) adapterView : null;
    int headersCount = listView == null ? 0 : listView.getHeaderViewsCount();
    if (headersCount > 0) {
        position -= listView.getHeaderViewsCount();
    }
    return position;
}