recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setHasFixedSize(true);//固定大小
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, LinearLayoutManager.VERTICAL));
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { //recyclerView滑到底部监听
if (dy>0){
int visibleItemCount=linearLayoutManager.getChildCount();
int totalCount=linearLayoutManager.getItemCount();
int firstPosition=linearLayoutManager.findFirstVisibleItemPosition();
if (!loading&&visibleItemCount+firstPosition>=totalCount){
loading=true;
onLoadMore();
}
}
}
});
RecyclerView简易加载更多
最新推荐文章于 2024-03-15 22:19:49 发布