Customizing List Items

So far, each of your list items only displays the title of a Crime using a simple TextView.

What do you do when you want to display more information in each list item? What if you want to customize the design of each list item? Moving your item view to a separate layout file will allow you to do both of these things while also cleaning up the code.

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.10). This layout calls for two TextViews and a CheckBox.

Figure 9.10  A handful of custom list items

You create a new layout for a list item view the same way you do for the view of ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition 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.