Detecting the scrolling direction in the adapter (up/down)

后端 未结 11 1586
臣服心动
臣服心动 2020-12-01 00:38

I am trying to mimic the Google Plus application in my project, as it seems to be the reference now.

The listview effect when scrolling is really nice and I would li

11条回答
  •  攒了一身酷
    2020-12-01 01:00

    list.setOnScrollListener(new OnScrollListener() {
            int last_item;
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
    
            }
    
            @Override
            public void onScroll(AbsListView view, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {
                if(last_itemfirstVisibleItem+visibleItemCount-1){
                    System.out.println("List is scrolling downwards");
                }
                 last_item = firstVisibleItem+visibleItemCount-1;
            }
        });
    

    Based on the position of the last visible item i decide whether Listview is going up or down.

提交回复
热议问题