在listview滚动上隐藏/显示搜索布局

时间:2017-09-05 09:04:47

标签: android listview

我在listview上面做了一个搜索布局,我想在listview滚动上隐藏/显示这个搜索布局,就像滚动facebook newsfeed show /隐藏新闻提要顶部的搜索栏我已经附上了我的截图请看屏幕截图并指导我这个。谢谢

screen shot of the view

这是我的listview滚动侦听器

在这个我试过但这不是我想要的。我想要像我之前所说的那样喜欢facbook新闻源。

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

    if (userScrolled && firstVisibleItem + visibleItemCount+1 == totalItemCount+1) {

        userScrolled = false;
        if (nextPage)
            updateListView();
    }
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    int position = bussinesList.getFirstVisiblePosition();
    View v = bussinesList.getChildAt(0);
    int offset = (v == null) ? 0 : v.getTop();

    if (mPosition < position || (mPosition == position && mOffset < offset)){
        // Scrolled up
        searchlayout.setVisibility(View.GONE);

    } else {
        // Scrolled down
        searchlayout.setVisibility(View.VISIBLE);

    }
    if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
        userScrolled = true;
        //linearlayout.setVisibility(View.GONE);
    }
}

0 个答案:

没有答案