如何监听RecyclerView划到最后一条数据

  
实现代码:

//RecyclerView的滑动监听
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
//当RecyclerView滑动时触发
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
//获取可见item个数
int lastVisibleItemPosition =
linearLayoutManager.findLastVisibleItemPosition();
//说明是最后一条数据
if (lastVisibleItemPosition + 1 == adapter.getItemCount()) {
Snackbar.make(mRecyclerView, "一次只加载20条,查看更多请刷新哦。",
Snackbar.LENGTH_SHORT).show();
}
}
});
posted @ 2017-04-26 19:55  浪浪暖男  阅读(1374)  评论(0编辑  收藏  举报