gpt4 book ai didi

android - 对于多个项目,.notifyItemInserted() 的替代方法是什么?

转载 作者:行者123 更新时间:2023-12-04 23:54:22 26 4
gpt4 key购买 nike

我正在使用 RecyclerView,.notifyItemInserted 仅将一项插入 RecyclerView。对于多个项目,我该怎么做?我想避免使用 .notifyDataSetChanged()

假设我有25个项目,我想插入另外20个,我会调用什么方法?

最佳答案

您可以使用 notifyItemRangeInserted 通知多次插入。

void notifyItemRangeInserted (int positionStart, int itemCount)

根据official documentation

Notify any registered observers that the currently reflected itemCount items starting at positionStart have been newly inserted. The items previously located at positionStart and beyond can now be found starting at position positionStart + itemCount.

关于android - 对于多个项目,.notifyItemInserted() 的替代方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60274999/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com