Creating a ListFragment

Create a new class named CrimeListFragment. Click Browse to choose a superclass. Search for and select ListFragment – and then click Finish to generate CrimeListFragment.

ListFragment was introduced in Honeycomb, but it is duplicated in the support library. So compatibility is not a problem as long as you use the support library class,

In, override onCreate(Bundle) to set the title of the activity that will host this fragment.

Listing 9.4  Adding onCreate(Bundle) to the new activity (

p​u​b​l​i​c​ ​c​l​a​s​s​ ​C​r​i​m​e​L​i​s​t​F​r​a​g​m​e​n​t​ ​e​x​t​e​n​d​s​ ​L​i​s​t​F​r​a​g​m​e​n​t​ ​{​

 ​ ​ ​ ​@​O​v​e​r​r​i​d​e​ ...

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.