Skip to content
Advertisement

Does recyclerView create many instances of items callBack listeners?

in recyclerView when I set on Click Listener to my viewHolders
how android handles this with callbacks?

which one is correct:

  • android creates listeners as much as we have items in memory
  • android creates one callback and many pointers to that callback?

Advertisement

Answer

Erm, the RecyclerView, recycles it view. So only the views viewable and a few each side would have listeners, and then once the user scrolls, the ones now not showing would be recreated into ones closer to the current scroll position.

So how many listeners you would have active at one time would depend on how many views are currently present +- a few each side.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement