Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView onClick notifyItemRemoved doesn't trigger onBindView

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

like image 955
wonTonx Avatar asked Oct 19 '15 08:10

wonTonx


1 Answers

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.

like image 145
Vipul Asri Avatar answered Dec 08 '22 00:12

Vipul Asri