onScroll gets called when I set listView.onScrollListener(this), but without any touch

后端 未结 5 1434
轻奢々
轻奢々 2020-12-29 02:27

When I set the onScrollListener for my ListView, it calls onScroll. This causes a crash because certain things haven\'t been initializ

5条回答
  •  -上瘾入骨i
    2020-12-29 03:08

    I use this solution and it works fine for me :

    public void onScrollStateChanged(AbsListView view, int scrollState) {
                if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
                    canScroll = false;
                } else if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING ||
                        scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
                    canScroll = true;
    
                }
            }
    

提交回复
热议问题