【问题标题】:How to show new item(update or add) in recycleview top in list如何在列表顶部的 recyclerview 中显示新项目(更新或添加)
【发布时间】:2019-01-26 06:37:47
【问题描述】:

如何在

中显示新项目(更新或添加)

recycleview列表中的顶部

【问题讨论】:

  • 更具体地问什么?
  • Rahul,我认为这个问题已被理解。我同意这不是描述性的。

标签: android mysql json


【解决方案1】:

在更新或添加方法中添加以下两行:

mArrayList.add(0, item);
notifyItemInserted(0); 

其中“item”是mArrayList的对象。

【讨论】:

    【解决方案2】:

    使用以下代码在 RecyclerView 顶部添加一个新项目:

    you_array_list.add(0, your_item);
    notifyItemInserted(0);
    mRecyclerView.smoothScrollToPosition(0);
    

    希望这会奏效。

    【讨论】:

      猜你喜欢
      • 2017-01-11
      • 1970-01-01
      • 2021-04-27
      • 1970-01-01
      • 2016-12-15
      • 2020-12-11
      • 1970-01-01
      • 2019-10-21
      • 1970-01-01
      相关资源
      最近更新 更多