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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.