How to get android Recyclerview updated item position after deletion/addition of item

91 Views Asked by At

I am using a paged list adapter with room database. How to get the "old position" and "new position" of an item after deletion/addition of other items. Any help would be appreciated

1

There are 1 best solutions below

0
Lerby-dev On

When you using ViewHolder in RecyclerView you override methods, some of them have got position. Example:

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { //TODO something}

Also you can use Map for save this position with something example title(if title not repeat). I hope that help you, but I mean other have a better advise.