DialogFragment

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

Object
   ↳ Fragment
     ↳ DialogFragment
Known direct subclasses
AppCompatDialogFragment

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

MediaRouteChooserDialogFragment

Media route chooser dialog fragment.

MediaRouteControllerDialogFragment

Media route controller dialog fragment.

PreferenceDialogFragmentCompat

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.

Summary

Constants

static final int

Style for setStyle: a basic, normal dialog.

static final 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 int

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

static final int

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

Public constructors

Constructor used by the default FragmentFactory.

DialogFragment(@LayoutRes 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

void

Dismiss the fragment and its dialog.

void

Version of dismiss that uses FragmentTransaction.commitAllowingStateLoss().

@Nullable Dialog

Return the Dialog this fragment is currently controlling.

boolean

Return the current value of setShowsDialog.

@StyleRes int
boolean

Return the current value of setCancelable.

@MainThread @Override 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 void

Called when a fragment is first attached to its context.

@Override void
@MainThread @Override 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 void

Remove dialog.

@MainThread @Override void

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

@Override void