【问题标题】:Recyclerview move to penultimate position when the list is update更新列表时,Recyclerview 移动到倒数第二个位置
【发布时间】:2022-08-16 08:40:59
【问题描述】:

目前我有下一个配置。

RecyclerView + MutableLiveData + DiffUtils

行为是:

当我移动到最后一个位置并更新列表时,RecyclerView 会自动移动到倒数第二个项目,但只发生在最后一个位置

    标签: android kotlin android-recyclerview mutablelivedata android-diffutils


    【解决方案1】:
    lst.insert(-1, l.pop(0))
    

    所以它遵循以下语法:

    lst.insert(new_index, l.pop(old-index))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多