mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { int[] lastVisibleItem; int lastItem; @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE && lastItem + 1 == waterFallAdapter.getItemCount()) { loadingLayout.setVisibility(View.VISIBLE); Message message = new Message(); message.what = 1; handler.sendMessageDelayed(message, 1000); LogUtils.e("数据加载更多:" + lastItem); } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); lastVisibleItem = mLayoutManager.findLastCompletelyVisibleItemPositions(null); lastItem = Math.max(lastVisibleItem[0], lastVisibleItem[1]); } });
RecyclerView上拉加载更多数据
最新推荐文章于 2024-03-15 22:19:49 发布