O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Customizing List Items

So far, each of your list items only displays the title of a Crime – the result of Crime.toString().

When you want to display more than just a string, you can create custom list items. Implementing custom list items requires two things:

  • creating a new layout in XML that defines the view for the list item

  • creating a subclass of ArrayAdapter<T> that knows how to create, populate, and return the view defined in the new layout

Creating the list item layout

For CriminalIntent, a list item’s layout should include the crime’s title, its date, and whether the case has been solved (Figure 9.11). This layout calls for two TextViews and a CheckBox.

Figure 9.11  A handful of custom list items

You create a new layout for a list item ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required