【问题标题】:Load item in recyclerview only after button click using paging library仅在使用分页库单击按钮后才在 recyclerview 中加载项目
【发布时间】:2023-03-20 21:44:01
【问题描述】:

我正在使用分页库在 recyclerview 中加载数据。它会在视图创建后立即加载数据。我需要限制它并且需要在单击按钮后发出请求并加载数据。

【问题讨论】:

  • 请贴出你已经完成的代码。

标签: android android-recyclerview android-paging-library


【解决方案1】:

你能分享你的代码吗?

观察时尝试将列表保存到变量中

然后将列表设置为按钮的适配器onClickListener()

【讨论】:

  • 需要像 instagram 搜索一样实现..加载时需要显示空列表,而搜索需要显示分页结果
  • 首先传递空列表然后在搜索时将原始列表设置为等于结果列表并使用 notifyDataSetChanged()
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-08
  • 1970-01-01
相关资源
最近更新 更多