5.2 ListView Performance
With a list view, as a cell is “pushed” off the screen due to scrolling, that cell or
Viewobject is moved into a
Recycler(not to be confused with
RecyclerView) and the same
Viewobject is reused by the system.
Diagram of how cells are recycled
If we look at the diagram above, when
Item 1is pushed offscreen, it is saved in the
Viewobject 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 1is checked, when the
Item 1's cell is reused, we’ll see that
Item 8is created with the checkbox already checked. The text in
Item 8has changed, but the
Viewobject itself has been reused. This is because the
Viewobjects in a list view are not attached to a certain position or item in the list.