I am trying to make an app that will be loading news from the network and will be updating dynamically. I am using a RecyclerView
and CardView
to display the content. I use Jsoup
to parse sites. I don't think that my code is needed because my question is more theoretical than practical. I want to understand the process of dynamic updating using notifyDataSetChanged()
. In my main activity I get all the headers and add them to list. But I need to wait untill all the items are loaded to start displaying them. I would really appreciate if someone could post a sample code of what I'm trying to do because I couldn't find a lot of information about combining ViewHolder
, Adapter
and RecyclerView
.
In your RecyclerView adapter
, you should have a ArrayList
and also one method addItemsToList(items)
to add list items to the ArrayList
. Then you can add list items by call adapter.addItemsToList(items)
dynamically. After all your list items added to the ArrayList
then you can call adapter.notifyDataSetChanged()
to display your list.
Hope this is clear!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With