LiveData and Adapters
See original GitHub issueWhat is the best way to handle adapter updates with data arriving only through LiveData?
With everything in Activity, you could call all methods, such as adapter.notifyItemAdded()
, but with LiveData you can only submit one type of item, generally whole list to display. That way you can only call adapter.notifyDataSetChanged()
which documentation states it should be used as last resort.
So is there any better way to do it, or do we just need to call adapter.notifyDataSetChanged()
from now on?
Issue Analytics
- State:
- Created 6 years ago
- Comments:22 (2 by maintainers)
Top Results From Across the Web
How to set LiveData from Adapter? - Stack Overflow
I set up an onClickListener in the ViewHolder class inside the RecyclerView.Adapter of the Library Fragment. So, when an item is clicked, the ......
Read more >Recycler View With MVVM Livedata - Medium
Live data is nothing just an observer pattern using ViewModel, ... Recycler View With MVVM Livedata ... Create Recyclerview Adapter xml
Read more >LiveAdapter, Android: RecyclerView Adapter for LiveData
Not even a ViewHolder! Based on Android Data Binding; Written in Kotlin; Supports LiveData; No need to write the adapter; No need to...
Read more >Flexible RecyclerView Adapter with MVVM and Data Binding
A RecyclerView Adapter that can handle multiple item types without ... value of our LiveData object which will be bound to the XML...
Read more >Why does recyclerview adapter often changes from livedata ...
Coding example for the question Why does recyclerview adapter often changes from livedata observer even though no changes are there?-kotlin.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think any of the solutions mentioned above has related to the Original Question, I want this issue to be reopened as currently I find no way to update a single item in RecyclerView Adapter using LiveData inside ViewModel, we have to set entire list everytime which I don’t think a better solution or technique.
I’d like to know this as well – I’m working with large (tenthousands of items) datasets, and need to handle their LiveData<List<…>> changing frequently. Just diffing them is a major waste of time. A LiveDataCollection type that can handle collections, and changes within them, would be a major improvement.