RecyclerView onClick notifyItemRemoved doesn't trigger onBindView

南笙酒味 提交于 2019-12-22 01:37:46

问题


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

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


回答1:


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

after using notifyItemRemoved(position) use 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.

Refer this RecyclerView insert /remove animation answer.



来源:https://stackoverflow.com/questions/33210414/recyclerview-onclick-notifyitemremoved-doesnt-trigger-onbindview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!