微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/android/311257.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐