Search code examples
androidlistviewprogress-barnotifydatasetchanged

Android: Updating single item in ListView without freezing the others


I have a ListView with items that are updated asynchronously(either their content is changed or the item is removed altogether). To do so I update the dataset for the adapter of the ListView and then I call notifyDatasetChanged() on the adapter. This works well, however each item has a ProgressBar (spinning), that indicates that the item has not been updated yet. When an update arrives for one of the items and notifyDatasetChanged() is called the ProgressBars of the other items freeze for a moment, which seems like a bad user experience. Also I use the ViewHolder pattern in my adapter.

Is there a way I could update just one item of the ListView, without freezing all the others?


Solution

  • Consider using RecyclerView - it has a big variety of notify...() methods.
    Have a look at this one - I think you can use it.
    You can simply make something like that :

    mAdapter.notifyItemChanged(itemChangedIndex);