android – RecyclerView onClick notifyItemRemoved不会触发onBindView

前端之家收集整理的这篇文章主要介绍了android – RecyclerView onClick notifyItemRemoved不会触发onBindView前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用notifyItemRemoved()方法我想要更改其他剩余的项,但该方法不会触发onBindView()方法.

除了使用notifyDataSetChanged()之外,我该如何做到这一点.我想要具有notifyItemRemoved()方法的动画

解决方法

如果您尝试从RecyclerView适配器中删除一个项目,并希望在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的答案.

原文链接:https://www.f2er.com/android/311257.html

猜你在找的Android相关文章