Understanding Dialog Fragments
In this section, you learn how to use dialog fragments to present a simple alert dialog and a custom dialog that is used to collect prompt text.
DialogFragment Basics
Before we show you working examples of a prompt dialog and an alert dialog, we would like to cover the high-level idea of dialog fragments. Dialog-related functionality uses a class called DialogFragment
. A DialogFragment
is derived from the class Fragment
and behaves much like a fragment. You will then use the DialogFragment
as the base class for your dialogs. Once you have a derived dialog from this class such as
public class MyDialogFragment extends DialogFragment { ... }
you can then show this dialog fragment MyDialogFragment
as a dialog using ...
Get Pro Android 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.