Android Programming Tutorials

(Romina) #1

TUTORIAL 5


Making Our List Be Fancy


In this tutorial, we will update the layout of our ListView rows, so they show


both the name and address of the restaurant, plus an icon indicating the


type. Along the way, we will need to create our own custom ListAdapter to


handle our row views and a RestaurantHolder to populate a row from a


restaurant.


Regarding the notion of adapters and ListAdapter, to quote from The Busy


Coder's Guide to Android Development:


In the abstract, adapters provide a common interface to
multiple disparate APIs. More specifically, in Android's case,

adapters provide a common interface to the data model
behind a selection-style widget, such as a listbox...Android's
adapters are responsible for providing the roster of data for a

selection widget plus converting individual elements of data
into specific views to be displayed inside the selection widget.

Step-By-Step Instructions..........................................................................


First, you need to have completed the previous tutorial. If you are


beginning the tutorials here, or if you wish to not use your existing work,


you can download a ZIP file with all of the tutorial results, and you can copy


the 04-ListView edition of LunchList to use as a starting point.


37
Free download pdf