Special-purpose fragment classes
Now that we understand the life cycle 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 that they all ultimately inherit from the Fragment
class and therefore experience the same life cycle behavior. Many of these specialized classes have an impact on which operations are safe to perform at the various points in the life cycle, and some of these classes even add their own life cycle methods. Understanding each of these classes and their interaction with the fragment life cycle is essential to 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 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...