A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.html
Dialog Designandroid
For information about how to design your dialogs, including recommendations for language, read the Dialogs design guide.app
The Dialog
class is the base class for dialogs, but you should avoid instantiating Dialog
directly. Instead, use one of the following subclasses:ide
AlertDialog
DatePickerDialog
or TimePickerDialog
Android includes another dialog class called ProgressDialog
that shows a dialog with a progress bar. However, if you need to indicate loading or indeterminate progress, you should instead follow the design guidelines for Progress & Activity and use aProgressBar
in your layout.ui
These classes define the style and structure for your dialog, but you should use a DialogFragment
as a container for your dialog. TheDialogFragment
class provides all the controls you need to create your dialog and manage its appearance, instead of calling methods on the Dialog
object.this
Using DialogFragment
to manage the dialog ensures that it correctly handles lifecycle events such as when the user presses the Backbutton or rotates the screen. The DialogFragment
class also allows you to reuse the dialog's UI as an embeddable component in a larger UI, just like a traditional Fragment
(such as when you want the dialog UI to appear differently on large and small screens).spa
The following sections in this guide describe how to use a DialogFragment
in combination with anAlertDialog
object. If you'd like to create a date or time picker, you should instead read the Pickers guide.code
Note: Because the DialogFragment
class was originally added with Android 3.0 (API level 11), this document describes how to use the DialogFragment
class that's provided with the Support Library. By adding this library to your app, you can use DialogFragment
and a variety of other APIs on devices running Android 1.6 or higher. If the minimum version your app supports is API level 11 or higher, then you can use the framework version of DialogFragment
, but be aware that the links in this document are for the support library APIs. When using the support library, be sure that you import android.support.v4.app.DialogFragment
class and not android.app.DialogFragment
.component