3.2 ListView Performance
Last updated
Last updated
With a list view, as a cell is “pushed” off the screen due to scrolling, that cell or View
object is moved into a Recycler
(not to be confused with RecyclerView
) and the same View
object is reused by the system.
If we look at the diagram above, when Item 1
is pushed offscreen, it is saved in the Recycler
and the View
object is reused for Item 8
. This can lead to all sorts of bugs.
Let’s say, for example, that every item had a checkbox. If the checkbox in Item 1
is checked, when the Item 1
's cell is reused, we’ll see that Item 8
is created with the checkbox already checked. The text in Item 8
has changed, but the View
object itself has been reused. This is because the View
objects in a list view are not attached to a certain position or item in the list.