4

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();
    }
General Grievance
  • 4,555
  • 31
  • 31
  • 45
maveroid
  • 1,840
  • 1
  • 20
  • 20

1 Answers1

10

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
    }
Anitha Manikandan
  • 1,160
  • 7
  • 19
  • Yes , I am trying this.. Will let you know whether it works.. See second answer on http://stackoverflow.com/questions/27300811/recyclerview-adapter-notifydatasetchanged-stops-fancy-animation – maveroid Jul 29 '15 at 10:06
  • Yes.. My solution is the same. I have tried and it worked for me! – Anitha Manikandan Jul 29 '15 at 10:09