Special purpose fragment classes
Now that we understand the lifecycle of fragments, we can look at some of the specialized versions of the Fragment
class. As we go through each of these specialized classes, remember they all ultimately inherit from the Fragment
class and therefore experience the same lifecycle behavior. Many of these specialized classes have an impact on what operations are safe to perform at the various points in the lifecycle, and some of these classes even add their own lifecycle methods. Understanding each of these classes and their interaction with the fragment lifecycle is essential for using the classes effectively.
ListFragment
One of the simplest fragment-derived classes to use and yet one of the most helpful is the ListFragment
class. The ListFragment
class provides a fragment that encapsulates a ListView
and, as the name implies, is useful for displaying lists of data.
Associating data with the list
Unlike the base Fragment
class, we're not required to override the...