android RecyclerView onScrolled not call

六眼飞鱼酱① 提交于 2020-02-03 10:27:15

问题


I want to load last chapter when pull down and load next chapter when pull up,but get some problems, when I inited the first page ,then I pull up to load last chapter, the recyclerview not call onScrolled. But if I pull down small distance then pull down ,I can get the result ,here is my code:

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled (RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    if(dy < 0 && mLayoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
        getNextChapter();
    }
    if(dy > 0 &&
        mLayoutManager.findLastCompletelyVisibleItemPosition() ==
        mAdapter.getItemCount() - 1) {
        getNextChapter();
     }
     Logger.i("onScrolled:" + dy);
    }
});

来源:https://stackoverflow.com/questions/41383305/android-recyclerview-onscrolled-not-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!