Chapter 9. GUI: ListView
9.1. Introduction: ListView
Discussion
It may seem odd to have a separate chapter for the ListView
component. But it is, in fact, one of the most important components,
being used in probably 80% of all Android applications. And it is very
flexible; you can do a lot with it, but figuring out how to do it is
sometimes not as intuitive as it could be.
In this chapter we cover topics from basic
ListView
uses through to advanced uses.
See the official doc at http://developer.android.com/reference/android/widget/ListView.html.
Another good overview of ListView
can be found
in a Google I/O 2010 presentation, which can be found on Google’s
YouTube channel, at http://www.youtube.com/watch?v=wDBM6wVEO70; this was
presented by Google employees Romain Guy and Adam Powell who work on the
code for ListView
itself.
9.2. Building List-Based Applications with ListView
Problem
Many mobile applications follow a similar pattern, allowing users to browse and interact with multiple items in a list. How can developers use standard Android UI classes to quickly build an app that works the way users will expect, providing them a list-based view onto their data?
Solution
Use a ListView
, an extremely versatile control
that is well suited to the screen size and control constraints of a
mobile application, displaying information in a vertical stack of rows.
This recipe shows how to set up a ListView
, including
rows that contain any combination of standard UI views.
Discussion ...
Get Android Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.