I have a RecyclerView
with rows that have views that when clicked will be disabled for that row position.
The problem is after I update the adapter like this:
adapterData.clear();
adapterData.addAll(refreshedAdapterData);
notifyDataSetChanged();
After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data.
When you call
notifyDataSetChanged()
, theonBindViewHolder()
method of every view is called. So you could add something like this in theonBindViewHolder()
of yourAdapter
method:I have resolved this by putting a conditional statement inside onBindViewHolder method instructing all positions to reset the disabled views if data meets the required conditions for a refreshed data.
@Christoph Mayr, thanks for your comments. It helped point me in the right direction.
Use below code.
OR