这里是我在滚动(嵌套滚动视图)上点击“加载更多”时发生的错误。该功能正常工作。似乎数据绑定中存在问题。
在xml中将recyclerview的嵌套滚动设置为false
android:nestedScrollingEnabled="false"
在嵌套滚动视图上应用分页
mNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if(v.getChildAt(v.getChildCount() - 1) != null) {
if ((scrollY >= (v.getChildAt(v.getChildCount() - 1).getMeasuredHeight() - v.getMeasuredHeight())) &&
scrollY > oldScrollY) {
visibleItemCount = mLayoutManager.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
if (isLoadData()) {
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
//Load your data here
}
}
}
}
}
});
public boolean isLoadData(){
return itemsReturnedPerPageCount > 0;
}