Recyclerview Refresh is divided into content changes and structural changes, structural changes such as remove and insert will not lead to viewholder updates, so sometimes we use
notifyitemremoved (position);
or use
notifyiteminserted (position);
The location of the item has not changed, or the location has been confused, it is strange and weird, need to recall
Notifydatasetchanged ();
To refresh the entire list for each item, but doing so will cause the Recyclerview to add and remove animations. Then want to have no bug insert Delete, and want to have animation how to do it, only need to refresh the delete location below the list of the item location, then fortunately Recyclerview has a local Refresh method:
notifyitemrangechanged (intint itemCount)
How to use it?
We only need to refresh the position of all the item below the change location item at the same time as delete or insert:
Insert Action:
notifyiteminserted (position); if (Position! = mdata.size ()) {- position);}
Delete action:
notifyitemremoved (position); if (Position! = mdata.size ()) {- position);}
Android resolves an issue where Recyclerview deleted item causes location confusion