public class DialogFragment extends Fragment implements LifecycleOwner, ViewModelStoreOwner, HasDefaultViewModelProviderFactory, LifecycleOwner, SavedStateRegistryOwner, ActivityResultCaller

   ↳ Fragment
     ↳ DialogFragment
Known direct subclasses

A special version of DialogFragment which uses an AppCompatDialog in place of a platform-styled dialog.


Media route chooser dialog fragment.


Media route controller dialog fragment.


Abstract base class which presents a dialog associated with a DialogPreference.

Static library support version of the framework's android.app.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.



static final @NonNull int

Style for setStyle: a basic, normal dialog.

static final @NonNull int

Style for setStyle: don't draw any frame at all; the view hierarchy returned by onCreateView is entirely responsible for drawing the dialog.

static final @NonNull int

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

static final @NonNull int

Style for setStyle: don't include a title area.

Public constructors

Constructor used by the default FragmentFactory.

DialogFragment(@LayoutRes @NonNull int contentLayoutId)

Alternate constructor that can be called from your default, no argument constructor to provide a default layout that will be inflated by onCreateView.

Public methods

@NonNull void

Dismiss the fragment and its dialog.

@NonNull void

Version of dismiss that uses FragmentTransaction.commitAllowingStateLoss().

@Nullable Dialog

Return the Dialog this fragment is currently controlling.

@NonNull boolean

Return the current value of setShowsDialog.

@StyleRes @NonNull int
@NonNull boolean

Return the current value of setCancelable.

@MainThread @Override @NonNull void
onActivityCreated(@Nullable Bundle savedInstanceState)

This method is deprecated.

use onCreateDialog for code touching the dialog created by onCreateDialog, onViewCreated for code touching the view created by onCreateView and onCreate for other initialization.

@MainThread @Override @NonNull void

Called when a fragment is first attached to its context.

@Override @NonNull void
@MainThread @Override @NonNull void
onCreate(@Nullable Bundle savedInstanceState)

Called to do initial creation of a fragment.

@MainThread @NonNull Dialog
onCreateDialog(@Nullable Bundle savedInstanceState)

Override to build your own custom Dialog container.

@MainThread @Override @NonNull void

Remove dialog.

@MainThread @Override @NonNull void

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

@Override @NonNull void
@Override @NonNull LayoutInflater
onGetLayoutInflater(@Nullable Bundle savedInstanceState)

Returns the LayoutInflater used to inflate Views of this Fragment.

@MainThread @Override @NonNull void

Called to ask the fragment to save its curre