Search code examples
androidandroid-recyclerviewnotifydatasetchanged

Android - disable notifydatasetchanged for existing items


Is it possible to disable the refresh of the RecyclerView for the items already existing ? Because when I refresh the RecyclerView after adding new items, we can see visually the refreshing of the RecyclerView. I think we can see the refreshing because of the ImageView in each items.

So I want to disable notifydatasetchangedfor existing items.


Solution

  • If you're using RecyclerView, you should use [notifyItemRangeInserted](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyItemRangeInserted(int, int)) method (and friends) to refresh only items that were added, instead of notifyDatasetChanged. You can also refresh only items that have changed (notifyItemChanged) or that an item has moved (notifyItemMoved)