Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

5. Adapters, ListViews, and Lists > How Do These Objects Interact? - Pg. 144

HOW DO THESE OBJECTS INTERACT? To understand how the ListView interacts with the Adapter , there are a few con- straints you must understand. First, lists could scroll on to infinity, at least from the point of view of the device. Yet, as you might have guessed, the phone has a limited amount of memory. This means that not every single list item can have its own entry in the list, because the device would quickly run out of space. Further, if the ListView had to lay out every single row right up front, it could be bogged down for an unacceptable amount of time. What Android does to solve these problems is to recycle list element rows. The process looks a little bit like this: 1. Android goes through the entire list, asking each row how large it would like to be (this is so it knows how large to draw the scroll indicator). 2. Once it knows roughly how big the entire ListView will be, it then requests views for the first screen, plus a buffer (so it won't have to stop and get more when the user starts scrolling). Your adapter will have to create, configure,