In earlier apps that used Fragment
s, you declared each Fragment
in an Activity
’s layout or, for a DialogFragment
, called its show method to create it. The Flag Quiz app demonstrated how to use multiple activities to host each of the app’s Fragment
s on a phone device. In this app, you’ll use only one Activity
to host all of the app’s Fragment
s. On a phonesized device, you’ll display one Fragment
at a time. On a tablet, you’ll always display the Fragment
containing the list of contacts and display the Fragment
s for viewing, adding and editing contacts as necessary at the app’s right side. You’ll use the FragmentManager
and FragmentTransactions to dynamically display Fragment
s. In addition, you’ll use Android’s Fragment
back stack—a data structure that stores Fragment
s in last-in-first-out (LIFO) order—to provide automatic support for the Android system bar’s back button and to allow the app to remove Fragment
s in the reverse order from which they were added.