实现代码:
//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();
}
}
});