gpt4 book ai didi

android - RecyclerView onClick notifyItemRemoved 不会触发 onBindView

转载 作者:IT老高 更新时间:2023-10-28 23:29:57 31 4
gpt4 key购买 nike

我使用 notifyItemRemoved() 方法我想更改其他剩余项目,但该方法不会触发 onBindView() 方法。

除了使用 notifyDataSetChanged() 之外,我该怎么做。我想要 notifyItemRemoved() 方法附带的动画

最佳答案

如果您尝试从 RecyclerView Adapter 中删除一个项目,并希望在 RecyclerView 的整个列表中显示动画。

使用notifyItemRemoved(position)后使用notifyItemRangeChanged(position, getItemCount());

notifyItemRemoved(position); - notifies the RecyclerView Adapter that data in adapter has been removed at a particular position.

notifyItemRangeChanged(position, getItemCount()); - notifies the RecyclerView Adapter that positions of element in adapter has been changed from position(removed element index to end of list), please update it.

请参阅 RecyclerView insert /remove animation回答。

关于android - RecyclerView onClick notifyItemRemoved 不会触发 onBindView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33210414/

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