问题
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