ListFragment, ListView, and ArrayAdapter

Instead of a spinner, you want CrimeListFragment’s ListView to show list items to the user. Each list item should contain data about an instance of Crime.

ListView is a subclass of ViewGroup, and each list item is displayed as a child View object of the ListView. Depending on the complexity of what you need the list to display, these child View objects can be complex View objects or very simple ones.

Your first implementation of providing list items for display will be simple: a list item will only display the title of a Crime, and the View object will be a simple TextView.

Figure 9.6  A ListView with child TextViews

In Figure 9.6, you can see eleven TextViews and a hint of a twelfth. If you were able ...

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