Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset recyclerView position item views to original state after refreshing adapter

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.

like image 664
S bruce Avatar asked Sep 10 '25 17:09

S bruce


1 Answers

Use below code.

  adapterData.clear();
adapterData.addAll(refreshedAdapterData);

adapter.notifyDataSetChanged();

OR

recyclerView.invalidate();
like image 97
Keyur Thumar Avatar answered Sep 13 '25 08:09

Keyur Thumar