2

I am changing my existing List View to Recycler View and am trying to create the corresponding Recycler View adapter. In my current list view adapter there is a method called notifyDataSetInvalidated() being used. what would be equivalent call for recycler view in order to invalidate data.

Minions
  • 1,273
  • 1
  • 11
  • 28
  • what's the functionality of notifyDataSetInvalidated()??? is it used to refresh adapter data??? if so, on recycler view, u can do that using notifyDataSetChanged() method. – Solaiman Hossain May 24 '17 at 09:11
  • https://stackoverflow.com/questions/23171077/notifydatasetchanged-vs-invalidatedata - for the difference. – Minions May 24 '17 at 09:18

1 Answers1

0

NotifyDataSetInvalidated equivalent will be two option.
Refresh UI from the adapter:

mAdapter.notifyDataSetChanged(); // When dataset of adapter changed

or refresh it from recyclerView itself:

recyclerView.invalidate(); // When adapter or its component changed 

In recyclerView there are many other opportunity. You can check this: https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html

Shohan Ahmed Sijan
  • 4,391
  • 1
  • 33
  • 39
  • 1
    according to this https://stackoverflow.com/questions/23171077/notifydatasetchanged-vs-invalidatedata it says they are different. can you explain how is it same? – Minions May 24 '17 at 09:17
  • I just modified my answer. The difference is invalidate reinitialize full adapter and notifyDataSetChanged reinitialize data.@Ramya – Shohan Ahmed Sijan May 24 '17 at 09:37