Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recycler View Add Remove Item Animations not showing in swapCursor

How to implement Recycler View Default Item Add/Remove Animations in swapCursor function. notifyDataSetChanged() won't show any animations.

public void swapCursor(Cursor newCursor) {
        mCursor = newCursor;
        notifyDataSetChanged();
    }
like image 212
maveroid Avatar asked Dec 24 '22 16:12

maveroid


1 Answers

Just set the following in activity,

recyclerView.setHasFixedSize(true);

And in adapter, write

 setHasStableIds(true); //in constructor 
@Override
    public long getItemId(int position) {
        return cameraImageArrayList.get(position).hashCode(); //Any unique id
    }
like image 91
Anitha Manikandan Avatar answered May 16 '23 06:05

Anitha Manikandan