added in version 22.1.0
belongs to Maven artifact


public class DialogFragment
extends Fragment implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener

Known Direct Subclasses
Known Indirect Subclasses

Static library support version of the framework's DialogFragment. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.




Style for setStyle(int, int): a basic, normal dialog.


Style for setStyle(int, int): don't draw any frame at all; the view hierarchy returned by onCreateView(LayoutInflater, ViewGroup, Bundle) is entirely responsible for drawing the dialog.


Style for setStyle(int, int): like STYLE_NO_FRAME, but also disables all input to the dialog.


Style for setStyle(int, int): don't include a title area.

Public constructors


Public methods

void dismiss()

Dismiss the fragment and its dialog.

void dismissAllowingStateLoss()

Version of dismiss() that uses FragmentTransaction.commitAllowingStateLoss().

Dialog getDialog()
boolean getShowsDialog()

Return the current value of setShowsDialog(boolean).

int getTheme()
boolean isCancelable()

Return the current value of setCancelable(boolean).

void onActivityCreated(Bundle savedInstanceState)

Called when the fragment's activity has been created and this fragment's view hierarchy instantiated.

void onAttach(Context context)

Called when a fragment is first attached to its context.

void onCancel(DialogInterface dialog)
void onCreate(Bundle savedInstanceState)

Called to do initial creation of a fragment.

Dialog onCreateDialog(Bundle savedInstanceState)

Override to build your own custom Dialog container.

void onDestroyView()

Remove dialog.

void onDetach()

Called when the fragment is no longer attached to its activity.

void onDismiss(DialogInterface dialog)
LayoutInflater onGetLayoutInflater(Bundle savedInstanceState)

Returns the LayoutInflater used to inflate Views of this Fragment.

void onSaveInstanceState(Bundle outState)

Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance of its process is restarted.

void onStart()

Called when the Fragment is visible to the user.

void onStop()

Called when the Fragment is no longer started.

void setCancelable(boolean cancelable)

Control whether the shown Dialog is cancelable.

void setShowsDialog(boolean showsDialog)

Controls whether this fragment should be shown in a dialog.

void setStyle(int style, int theme)

Call to customize the basic appearance and behavior of the fragment's dialog.

int show(FragmentTransaction transaction, String tag)

Display the dialog, adding the fragment using an existing transaction and then committing the transaction.

void show(FragmentManager manager, String tag)

Display the dialog, adding the fragment to the given FragmentManager.

void showNow(FragmentManager manager, String tag)

Display the dialog, immediately adding the fragment to the given FragmentManager.

Inherited methods

From class