I have a item in RecyclerView
which does not need to be updated when I call notifyDataSetChanged
.
But I didn't find any methods to make the specified item avoid updated. Is it possible to do this ?
I need to do this because the item is a WebView
, it had loaded a html page, if I called notifyDataSetChanged
, this item will flash.
The reason why I post this question is avoiding the flash of the WebView
when notifyDataSetChanged
(see this quesion). After the failure of using notifyItemRangeXXX
methods, I post this question.
But after checking your answers and comments, it seems that it's impossible to avoid updating when using notifyDataSetChanged
.
The purpose of notifyDataSetChanged
IS to update ALL items. Don't use it if you don't want this behavior!
The correct approach would be to only update the data you've changed. There are some methods which will help you to only invalidate the desired data:
notifyItemChanged(int position)
notifyItemInserted(int position)
notifyItemMoved(int fromPosition, int toPosition)
notifyItemRangeChanged(int positionStart, int itemCount)
notifyItemRangeRemoved(int positionStart, int itemCount)
notifyItemRemoved(int position)