我正在使用 RecyclerView,.notifyItemInserted
仅将一项插入 RecyclerView。对于多个项目,我该怎么做?我想避免使用 .notifyDataSetChanged()
。
假设我有25个项目
,我想插入另外20个
,我会调用什么方法?
最佳答案
您可以使用 notifyItemRangeInserted
通知多次插入。
void notifyItemRangeInserted (int positionStart, int itemCount)
Notify any registered observers that the currently reflected
itemCount
items starting atpositionStart
have been newly inserted. The items previously located atpositionStart
and beyond can now be found starting at positionpositionStart + itemCount
.
关于android - 对于多个项目,.notifyItemInserted() 的替代方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60274999/