×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Mat Ba
Added: Oct 25, 2020 5:42 AM
Views: 4519
Tags: no tags
  1. 1) REMOVE: There are 4 steps to remove an item from a RecyclerView
  2.  
  3.  - list.remove(position);
  4.  - recycler.removeViewAt(position);
  5.  - mAdapter.notifyItemRemoved(position);
  6.  - mAdapter.notifyItemRangeChanged(position, list.size());
  7.  
  8.  
  9. 2) UPDATE THE DATA: The only things I had to do is
  10.  
  11. mAdapter.notifyDataSetChanged();
  12.  
  13. You had to do all of this in the Actvity/Fragment code not in the RecyclerView Adapter code.
  14.