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 @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

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 current dynamic state, so it can later be reconstructed in a new instance if its process is restarted.

@MainThread @Override @NonNull void

Called when the Fragment is visible to the user.

@MainThread @Override @NonNull void

Called when the Fragment is no longer started.

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

Called when all saved state has been restored into the view hierarchy of the fragment.

final @NonNull Dialog

Return the Dialog this fragment is currently controlling.

@NonNull void
setCancelable(@NonNull boolean cancelable)

Control whether the shown Dialog is cancelable.

@NonNull void
setShowsDialog(@NonNull boolean showsDialog)

Controls whether this fragment should be shown in a dialog.

@NonNull void
setStyle(
    @DialogFragment.DialogStyle @NonNull int style,
    @StyleRes @NonNull int theme
)

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

@NonNull void

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

@NonNull int

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

@NonNull void

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

Inherited methods

From class ActivityResultCaller
abstract @NonNull ActivityResultLauncher<@NonNull I>

Register a request to start an activity for result, designated by the given contract.

abstract @NonNull ActivityResultLauncher<@NonNull I>

Register a request to start an activity for result, designated by the given contract.

From class ComponentCallbacks
From class Fragment
@NonNull void
dump(
    @NonNull String prefix,
    @Nullable FileDescriptor fd,
    @NonNull PrintWriter writer,
    @Nullable Array<@NonNull String> args
)

Print the Fragments's state into the given stream.

final @Override @NonNull boolean

Subclasses can not override equals().

final @Nullable FragmentActivity

Return the FragmentActivity this fragment is currently associated with.

@NonNull boolean

Returns whether the the exit transition and enter transition overlap or not.

@NonNull boolean

Returns whether the the return transition and reenter transition overlap or not.

final @Nullable Bundle

Return the arguments supplied when the fragment was instantiated, if any.

final @NonNull FragmentManager

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

@Nullable Context

Return the Context this fragment is currently associated with.

@NonNull @Override ViewModelProvider.Factory

Returns the default that should be used when no custom Factory} is provided to the constructors.

@Nullable Object

Returns the Transition that will be used to move Views into the initial scene.

@Nullable Object

Returns the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.

final @Nullable FragmentManager

This method is deprecated.

This has been removed in favor of getParentFragmentManager() which throws an IllegalStateException if the FragmentManager is null.

final @Nullable Object

Return the host object of this fragment.

final @NonNull int

Return the identifier this fragment is known by.

final @NonNull LayoutInflater

Returns the cached LayoutInflater used to inflate Views of this Fragment.

@Override @NonNull Lifecycle

Returns the Lifecycle of the provider.

@NonNull LoaderManager

This method is deprecated.

Use LoaderManager.getInstance(this).

final @Nullable Fragment

Returns the parent Fragment containing this Fragment.

final @NonNull FragmentManager

Return the FragmentManager for interacting with fragments associated with this fragment's activity.

@Nullable Object

Returns the Transition that will be used to move Views in to the scene when returning due to popping a back stack.

final @NonNull Resources

Return requireActivity().getResources().

final @NonNull boolean

This method is deprecated.

Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.

@Nullable Object

Returns the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.

final @NonNull @Override SavedStateRegistry

Returns owned SavedStateRegistry

@