Hi, how to remove item at specific position in Rec...
# android
h
Hi, how to remove item at specific position in RecyclerView using paging library 3?
😶 6
m
I assume that you expose some kind of onClick listener that’d execute that remove logic. For instance a lambda which takes the itemId: (String) -> Unit Then delegate that action to your ViewModel ( assuming you use MVVM ), and use the
filter
operator the
PagingData<T>
to return a new PagingData without that ID. Additionally if you use room or any kind of other local persistence, and you get your
Paging<T>
from a local source then just delete that item in the local persistence. ( assuming you expose a observable from the local persistence )
h
Yes but next time i clicked on item second time but its position is wrong
m
How do you keep track of the position, if the 2nd time it doesn’t work that means you have a stale dataset. Instead of the position try using an ID, but still look into this ☝️
h
When i refresh list then its create problem with position