ComponentDialog


public class ComponentDialog extends Dialog implements LifecycleOwner, OnBackPressedDispatcherOwner, NavigationEventDispatcherOwner, SavedStateRegistryOwner

Known direct subclasses
AppCompatDialog

Base class for AppCompat themed android.app.Dialogs.

Known indirect subclasses
AlertDialog

A subclass of Dialog that can display one, two or three buttons.

MediaRouteChooserDialog

This class implements the route chooser dialog for MediaRouter.

MediaRouteControllerDialog

This class implements the route controller dialog for MediaRouter.


Base class for dialogs that enables composition of higher level components.

Summary

Public constructors

ComponentDialog(@NonNull Context context, @StyleRes int themeResId)

Public methods

void
@NonNull Lifecycle
@NonNull NavigationEventDispatcher

Lazily provides a NavigationEventDispatcher for back navigation handling, including support for predictive back gestures introduced in Android 13 (API 33+).

final @NonNull OnBackPressedDispatcher

Retrieve the OnBackPressedDispatcher that will be triggered when onBackPressed is called.

@NonNull SavedStateRegistry
void

Sets the view tree owners before setting the content view so that the inflation process and attach listeners will see them already present.

void
@NonNull Bundle
void
setContentView(int layoutResID)
void
void

Protected methods

void
@CallSuper
onCreate(Bundle savedInstanceState)
void
void

Inherited methods

From android.app.Dialog
void
void
void
void
boolean
boolean
boolean
boolean
boolean
boolean
@NonNull T
<T extends View> findViewById(int p0)
@Nullable ActionBar
final @NonNull Context
@Nullable View
@NonNull LayoutInflater
@NonNull OnBackInvokedDispatcher
final @Nullable Activity
final @Nullable SearchEvent
final int
@Nullable Window
void
void
boolean
void
void
void
void
boolean
void
void
boolean
boolean
View
void
boolean
boolean
onKeyDown(int p0, @NonNull KeyEvent p1)
boolean
boolean
onKeyMultiple(int p0, int p1, @NonNull KeyEvent p2)
boolean
boolean
onKeyUp(int p0, @NonNull KeyEvent p1)
boolean
boolean
onMenuOpened(int p0, @NonNull Menu p1)
boolean
void
void
onPanelClosed(int p0, @NonNull Menu p1)
boolean
boolean
onPreparePanel(int p0, @Nullable View p1, @NonNull Menu p2)
void
boolean
boolean
boolean
boolean
void
void
ActionMode
ActionMode
void
void
void
final boolean
final @NonNull T
<T extends View> requireViewById(int p0)
void
void
setCancelable(boolean p0)
void
void
final void
final void
setFeatureDrawableAlpha(int p0, int p1)
final void
setFeatureDrawableResource(int p0, int p1)
final void
void
void
void
void
final void
void
void
setTitle(int p0)
final void
void
void
takeKeyEvents(boolean p0)
void
From android.view.Window.Callback
void
void

Public constructors

ComponentDialog

Added in 1.5.0
public ComponentDialog(@NonNull Context context, @StyleRes int themeResId)

Public methods

addContentView

public void addContentView(@NonNull View view, ViewGroup.LayoutParams params)

getLifecycle

Added in 1.5.0
public @NonNull Lifecycle getLifecycle()

getNavigationEventDispatcher

public @NonNull NavigationEventDispatcher getNavigationEventDispatcher()

Lazily provides a NavigationEventDispatcher for back navigation handling, including support for predictive back gestures introduced in Android 13 (API 33+).

This dispatcher acts as the central point for back navigation events. When a navigation event occurs (e.g., a back gesture), it safely invokes ComponentDialog.onBackPressed.

getOnBackPressedDispatcher

public final @NonNull OnBackPressedDispatcher getOnBackPressedDispatcher()

Retrieve the OnBackPressedDispatcher that will be triggered when onBackPressed is called.

Returns
@NonNull OnBackPressedDispatcher

The OnBackPressedDispatcher associated with this ComponentDialog.

getSavedStateRegistry

Added in 1.7.0
public @NonNull SavedStateRegistry getSavedStateRegistry()

initializeViewTreeOwners

Added in 1.8.0
@CallSuper
public void initializeViewTreeOwners()

Sets the view tree owners before setting the content view so that the inflation process and attach listeners will see them already present.

onBackPressed

Added in 1.6.0
@CallSuper
public void onBackPressed()

onSaveInstanceState

public @NonNull Bundle onSaveInstanceState()

setContentView

public void setContentView(int layoutResID)

setContentView

public void setContentView(@NonNull View view)

setContentView

public void setContentView(@NonNull View view, ViewGroup.LayoutParams params)

Protected methods

onCreate

@CallSuper
protected void onCreate(Bundle savedInstanceState)

onStart

@CallSuper
protected void onStart()

onStop

@CallSuper
protected void onStop()