Does notifyItemChanged () force onBindViewHolder ()?

When I call notifyItemChanged()

on mine RecyclerView

, the corresponding Views

(in this case, buttons) does not update as expected. The reason I am calling them is because the data has changed, which will cause their background color to change. Does this mean that notifyItemChanged(

) does not trigger a challenge onBindViewHolder()

?

I tried using notifyDataSetChanged()

and it causes the views to be reloaded as I want, so I know my implementation is correct. (Note: I don't want to use notifyDataSetChanged()

it as it is ineffective, I only used it as a sanity test).

+3


source to share


1 answer


Refresh your list. Register a new observer to listen for data changes. using registerAdapterDataObserver

The adapter can publish various events describing specific changes. Not all adapters may support all types of changes, and some may fall back to the generic "something changed" event if more specific data is not available.



Components that register observers with an adapter are responsible for unregistering those observers when finished.

+1


source







All Articles