RecyclerView onClick notifyItemRemoved不会触发onBindView [英] RecyclerView onClick notifyItemRemoved doesn't trigger onBindView

查看:108
本文介绍了RecyclerView onClick notifyItemRemoved不会触发onBindView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I use notifyItemRemoved() method I want to change other remaining item , but the method doesn't trigger onBindView() method.

除了使用notifyDataSetChanged()之外,我该如何做.我想拥有notifyItemRemoved()方法随附的动画

How can I do that, except using the notifyDataSetChanged(). I want to have the animation that comes with notifyItemRemoved() method

推荐答案

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

If you are trying to remove an item from RecyclerView Adapter and want to show animation all over your list in RecyclerView.

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

notifyItemRemoved(position); -通知RecyclerView Adapter适配器中的数据已在特定位置被删除.

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

notifyItemRangeChanged(position,getItemCount()); -通知RecyclerView Adapter适配器中元素的位置已经 从位置更改(从元素索引删除到列表末尾),请 更新它.

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插入/删除动画答案.

这篇关于RecyclerView onClick notifyItemRemoved不会触发onBindView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆