jensiepoo
jensiepoo

Reputation: 579

How to modify notifyDataSetChanged to avoid onBindViewHolder being called

Assuming that the current item we're displaying in a recycler view is always the correct one even if the index of it changes, how do we simply modify the data set without/or delay, the call to onVindViewHolder to the next time we swipe?

Upvotes: 0

Views: 460

Answers (1)

Bui Quang Huy
Bui Quang Huy

Reputation: 1794

I think we no need to modify notifyDataSetChanged() in this case. Just need to create boolean variable like:

boolean firstLoad = true;

then check it in onBindViewHolder() to skip the first time, set it to false to bind data in the second time we swipe (scroll)

Upvotes: 1

Related Questions