ComponentDialog


open class ComponentDialog : Dialog, 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(context: Context, themeResId: @StyleRes Int)

Public functions

open Unit
open Unit

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

open Unit

This function is deprecated. This method has been deprecated in favor of using the {@link OnBackPressedDispatcher} via {@link #getOnBackPressedDispatcher()}.

open Bundle
open Unit
setContentView(layoutResID: Int)
open Unit
open Unit

Protected functions

open Unit
@CallSuper
onCreate(savedInstanceState: Bundle?)
open Unit
open Unit

Public properties

open Lifecycle
open NavigationEventDispatcher

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

final OnBackPressedDispatcher

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

open SavedStateRegistry

Inherited functions

From android.app.Dialog
Unit
Unit
Unit
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
T
<T : View> findViewById(id: Int)
Unit
Unit
Unit
Unit
Unit
Unit
Boolean
Unit
Unit
onCreateContextMenu(
    menu: ContextMenu,
    v: View,
    menuInfo: ContextMenu.ContextMenuInfo
)
Boolean
Boolean
onCreatePanelMenu(featureId: Int, menu: Menu)
View?
onCreatePanelView(featureId: Int)
Unit
Boolean
Boolean
onKeyDown(keyCode: Int, event: KeyEvent)
Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent)
Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent)
Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent)
Boolean
onKeyUp(keyCode: Int, event: KeyEvent)
Boolean
onMenuItemSelected(featureId: Int, item: MenuItem)
Boolean
onMenuOpened(featureId: Int, menu: Menu)
Boolean
Unit
Unit
onPanelClosed(featureId: Int, menu: Menu)
Boolean
Boolean
onPreparePanel(featureId: Int, view: View?, menu: Menu)
Unit
onRestoreInstanceState(savedInstanceState: Bundle)
Boolean
Boolean
Boolean
Boolean
Unit
Unit
ActionMode?
ActionMode?
Unit
Unit
Unit
Boolean
T
<T : View> requireViewById(id: Int)
Unit
Unit
Unit
Unit
Unit
setFeatureDrawable(featureId: Int, drawable: Drawable?)
Unit
setFeatureDrawableAlpha(featureId: Int, alpha: Int)
Unit
setFeatureDrawableResource(featureId: Int, resId: Int)
Unit
setFeatureDrawableUri(featureId: Int, uri: Uri?)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
setTitle(titleId: Int)
Unit
Unit
Unit
From android.view.Window.Callback
Unit
Unit
onProvideKeyboardShortcuts(
    data: MutableList<KeyboardShortcutGroup>,
    menu: Menu?,
    deviceId: Int
)

Public constructors

ComponentDialog

Added in 1.5.0
ComponentDialog(context: Context, themeResId: @StyleRes Int = 0)

Public functions

addContentView

open fun addContentView(view: View, params: ViewGroup.LayoutParams?): Unit

initializeViewTreeOwners

Added in 1.8.0
@CallSuper
open fun initializeViewTreeOwners(): Unit

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
open fun onBackPressed(): Unit

onSaveInstanceState

open fun onSaveInstanceState(): Bundle

setContentView

open fun setContentView(layoutResID: Int): Unit

setContentView

open fun setContentView(view: View): Unit

setContentView

open fun setContentView(view: View, params: ViewGroup.LayoutParams?): Unit

Protected functions

onCreate

@CallSuper
protected open fun onCreate(savedInstanceState: Bundle?): Unit

onStart

@CallSuper
protected open fun onStart(): Unit

onStop

@CallSuper
protected open fun onStop(): Unit

Public properties

lifecycle

Added in 1.5.0
open val lifecycleLifecycle
Added in 1.12.0
open val navigationEventDispatcherNavigationEventDispatcher

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.

onBackPressedDispatcher

final val onBackPressedDispatcherOnBackPressedDispatcher

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

Returns
OnBackPressedDispatcher

The OnBackPressedDispatcher associated with this ComponentDialog.

savedStateRegistry

Added in 1.7.0
open val savedStateRegistrySavedStateRegistry