【问题标题】:RecyclerView pull UP to refreshRecyclerView 上拉刷新
【发布时间】:2014-09-23 01:33:13
【问题描述】:

如何检测回收站视图何时位于列表底部,而不是仅位于屏幕底部,而是位于 RecyclerView 中的最后一项。现在我正在使用 SwipeRefreshLayout 但我不能将它设置为上拉。

【问题讨论】:

标签: java android android-recyclerview


【解决方案1】:

onScrolled() 回调中使用此代码。

int lastVisibleItem = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
int totalItemCount = layoutManager.getItemCount();

if (lastVisibleItem >= totalItemCount - 10) {
   loadMore();
}

【讨论】:

    【解决方案2】:

    添加一个滚动监听器。

    RecyclerView.addOnScrollListener(OnScrollListener listener)

    【讨论】:

      猜你喜欢
      • 2017-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 2018-08-22
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多