The onDestroyView callback method is called to clean up any user interface

The ondestroyview callback method is called to clean

This preview shows page 15 - 22 out of 55 pages.

The onDestroyView() callback method is called to clean up any user interface layout, or View hierarchy resources, associated with the Fragment . The onDestroy() callback method is called to clean up any other resources associated with the Fragment . The onDetach() callback method is called just before the Fragment is detached from the Activity class.
Image of page 15

Subscribe to view the full document.

Working with Special Types of Fragments There are some specialty Fragment classes you’ll want to familiarize yourself with, including the following: ListFragment ( android.app.ListFragment ) PreferenceFragment ( android.preference.PreferenceFragment ) WebViewFragment ( android.webkit.WebViewFragment ) DialogFragment ( android.app.DialogFragment )
Image of page 16
Working with Special Types of Fragments ListFragment Much like a ListActivity , this Fragment class hosts a ListView control. PreferenceFragment Much like a PreferenceActivity , this Fragment class lets you easily manage user preferences. WebViewFragment This type of Fragment hosts a WebView control to easily render Web content. Your application will still need the android.permission.INTERNET permission to access the Internet. DialogFragmen t Decoupling user interface functionality from your Activity classes means you won’t want your dialogs managed by the Activity either. Instead, you can use this class to host and manage Dialog controls as fragments. Dialogs can be traditional pop-ups or embedded.
Image of page 17

Subscribe to view the full document.

Designing Fragment -Based Applications Here we can see the sample application provided with this chapter. The application uses a ListFragment for the list of veggies, as seen on the left, and a WebViewFragment to display each blog post describing a veggie, as seen on the right. In portrait mode, we will display one Fragment per screen, requiring two Activity classes.
Image of page 18
Designing Fragment -Based Applications (Cont’d) In landscape mode, we will display both fragments on the same screen within the same Activity class, as shown here.
Image of page 19

Subscribe to view the full document.