Home > Mobile >  how to update the data in specific position in the recyclerview without notifying the whole item? (E
how to update the data in specific position in the recyclerview without notifying the whole item? (E

Time:01-13

I need the functionality to update the data in the item in the recycler view. right now, If we notify the whole item it shows some fluctuation and we want to avoid refreshing the whole item on the UI.

I am using the ListAdapter with diff utils.

CodePudding user response:

You need to create custom Adapter:

https://developer.android.com/develop/ui/views/layout/recyclerview

CodePudding user response:

There are many ways to achieve your goal.

  1. self-managing items. Adapter doesn't know anything about content of the items, it only puts items into RecyclerView. Content is managed by the item itself, so your problem is already solved.
  2. custom adapter. Adapter has intricate knowledge about every item and can update selected ones accordingly.
  3. AsyncListDiffer You can add differ to your adapter and it will take care of not updating parts that need no update.

Without seeing your code, we can't tell which way would be the most appropriate for you, but I guess adding differ is the simplest on already working code.

  • Related