8.3.1. Displaying Fragments with FragmentTransactions

In earlier apps that used Fragments, 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 Fragments on a phone device. In this app, you’ll use only one Activity to host all of the app’s Fragments. 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 Fragments for viewing, adding and editing contacts as necessary at the app’s right side. You’ll use the FragmentManager and FragmentTransactions to dynamically display Fragments. In addition, you’ll use Android’s Fragment back stack—a data structure that stores Fragments 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 Fragments in the reverse order from which they were added.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset