how to detect Android ListView Scrolling stopped?

后端 未结 2 1260
鱼传尺愫
鱼传尺愫 2020-12-01 03:17

I\'m trying to do something after scrolling stopped.So, I tried using OnScrollListener#onScrollStateChanged(SCROLL_STATE_IDLE) to detect when the scrolling stop

2条回答
  •  盖世英雄少女心
    2020-12-01 03:21

    Try using the setOnScrollListener and implement the onScrollStateChanged with scrollState == 0 ... do what you need to do...

    setOnScrollListener(new OnScrollListener() {
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            // TODO Auto-generated method stub
        }
    
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                Log.i("a", "scrolling stopped...");
            }
        }
    });
    

提交回复
热议问题