# AlertDialog

Artifact: [androidx.appcompat:appcompat](https://developer.android.com/jetpack/androidx/releases/appcompat) [View Source](https://cs.android.com/search?q=file:androidx/appcompat/app/AlertDialog.java+class:androidx.appcompat.app.AlertDialog) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

*** ** * ** ***


```
class AlertDialog : AppCompatDialog, DialogInterface
```

<br />

|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||||
| ↳ | [android.app.Dialog](https://developer.android.com/reference/android/app/Dialog.html) ||||
|   | ↳ | [androidx.activity.ComponentDialog](https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog) |||
|   |   | ↳ | [androidx.appcompat.app.AppCompatDialog](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog) ||
|   |   |   | ↳ | [androidx.appcompat.app.AlertDialog](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog) |

Known direct subclasses [MediaRouteControllerDialog](https://developer.android.com/reference/kotlin/androidx/mediarouter/app/MediaRouteControllerDialog)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/mediarouter/app/MediaRouteControllerDialog` | This class implements the route controller dialog for `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter`. |

*** ** * ** ***

A subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method. If you want to display a more complex view, look up the FrameLayout called "custom" and add your view to it:

```kotlin
FrameLayout fl = findViewById(android.R.id.custom);
fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
```

The AlertDialog class takes care of automatically setting `https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_ALT_FOCUSABLE_IM` for you based on whether any views in the dialog return true from `https://developer.android.com/reference/android/view/View.html#onCheckIsTextEditor()`. Generally you want this set for a Dialog without text editors, so that it will be placed on top of the current input method UI. You can modify this behavior by forcing the flag to your desired mode after calling `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#onCreate(android.os.Bundle)`.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder` |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#AlertDialog(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#AlertDialog(android.content.Context,int)(context: https://developer.android.com/reference/android/content/Context.html, themeResId: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Construct an AlertDialog that uses an explicit theme. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#AlertDialog(android.content.Context,boolean,android.content.DialogInterface.OnCancelListener)( context: https://developer.android.com/reference/android/content/Context.html, cancelable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, cancelListener: https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html? )` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/android/widget/Button.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#getButton(int)(whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Gets one of the buttons used in the dialog. |
| `https://developer.android.com/reference/android/widget/ListView.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#getListView()()` Gets the list view used in the dialog. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#onKeyDown(int,android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#onKeyUp(int,android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setButton(int,java.lang.CharSequence,android.content.DialogInterface.OnClickListener)( whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Sets a listener to be invoked when the positive button of the dialog is pressed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setButton(int,java.lang.CharSequence,android.os.Message)(whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, msg: https://developer.android.com/reference/android/os/Message.html!)` Sets a message to be sent when a button is pressed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setButton(int,java.lang.CharSequence,android.graphics.drawable.Drawable,android.content.DialogInterface.OnClickListener)( whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Sets an icon to be displayed along with the button text and a listener to be invoked when the positive button of the dialog is pressed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setCustomTitle(android.view.View)(customTitleView: https://developer.android.com/reference/android/view/View.html!)` This method has no effect if called after `https://developer.android.com/reference/android/app/Dialog.html#show()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setIcon(android.graphics.drawable.Drawable)(icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!)` Set the `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` to be used in the title. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setIcon(int)(resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set resId to 0 if you don't want an icon. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setIconAttribute(int)(attrId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setMessage(java.lang.CharSequence)(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!)` Sets the message to display. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html!)` Set the view to display in the dialog. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#setView(android.view.View,int,int,int,int)( view: https://developer.android.com/reference/android/view/View.html!, viewSpacingLeft: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, viewSpacingTop: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, viewSpacingRight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, viewSpacingBottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Set the view to display in the dialog, specifying the spacing to appear around that view. |

| ### Protected functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog#onCreate(android.os.Bundle)(savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html!)` |

### Inherited Constants

From [android.content.DialogInterface](https://developer.android.com/reference/android/content/DialogInterface.html) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON1 = -1`

**This property is deprecated.**
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON2 = -2`

**This property is deprecated.**
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON3 = -3`

**This property is deprecated.**
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEGATIVE = -2` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEUTRAL = -3` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE = -1`

### Inherited functions

From [androidx.appcompat.app.AppCompatDialog](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#addContentView(android.view.View,android.view.ViewGroup.LayoutParams)(view: https://developer.android.com/reference/android/view/View.html, params: https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#dismiss()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#dispatchKeyEvent(android.view.KeyEvent)(event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `T?` `<T : https://developer.android.com/reference/android/view/View.html?> https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#findViewById(int)(id: @https://developer.android.com/reference/kotlin/androidx/annotation/IdRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDelegate` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#getDelegate()()` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/ActionBar!` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#getSupportActionBar()()`

Support library version of `https://developer.android.com/reference/android/app/Dialog.html#getActionBar()`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#onStop()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#onSupportActionModeFinished(androidx.appcompat.view.ActionMode)(mode: https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode!)`

Called when a support action mode has finished.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#onSupportActionModeStarted(androidx.appcompat.view.ActionMode)(mode: https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode!)`

Called when a support action mode has been started.
`https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode?` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#onWindowStartingSupportActionMode(androidx.appcompat.view.ActionMode.Callback)(callback: https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode.Callback!)`

Called when a support action mode is being started for this window.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#setContentView(int)(layoutResID: @https://developer.android.com/reference/kotlin/androidx/annotation/LayoutRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#setContentView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#setContentView(android.view.View,android.view.ViewGroup.LayoutParams)(view: https://developer.android.com/reference/android/view/View.html, params: https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#setTitle(int)(titleId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatDialog#supportRequestWindowFeature(int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Enable extended support library window features.
From [androidx.activity.ComponentDialog](https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#addContentView(android.view.View,android.view.ViewGroup.LayoutParams)(view: https://developer.android.com/reference/android/view/View.html!, params: https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html!)` `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle!` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#getLifecycle()()`

The `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle` of this owner.
`https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher!` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#getNavigationEventDispatcher()()`

Lazily provides a `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` for back navigation handling, including support for predictive back gestures introduced in Android 13 (API 33+).
`https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher!` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#getOnBackPressedDispatcher()()`

Retrieve the `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` that will be triggered when `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressed()` is called.
`https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistry!` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#getSavedStateRegistry()()`

The `https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistry` owned by this `https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistryOwner`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#initializeViewTreeOwners()()`

Sets the view tree owners before setting the content view so that the inflation process and attach listeners will see them already present.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onBackPressed()()`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onCreate(android.os.Bundle)(savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html!)` `https://developer.android.com/reference/android/os/Bundle.html!` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onSaveInstanceState()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onStart()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#onStop()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog#setContentView(int)(layoutResID: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` From [android.app.Dialog](https://developer.android.com/reference/android/app/Dialog.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#addContentView(android.view.View, android.view.ViewGroup.LayoutParams)(view: https://developer.android.com/reference/android/view/View.html!, params: https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#closeOptionsMenu()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#create()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchGenericMotionEvent(android.view.MotionEvent)(ev: https://developer.android.com/reference/android/view/MotionEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchKeyEvent(android.view.KeyEvent)(event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchKeyShortcutEvent(android.view.KeyEvent)(event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)(event: https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchTouchEvent(android.view.MotionEvent)(ev: https://developer.android.com/reference/android/view/MotionEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#dispatchTrackballEvent(android.view.MotionEvent)(ev: https://developer.android.com/reference/android/view/MotionEvent.html!)` `T!` `<T : https://developer.android.com/reference/android/view/View.html?> https://developer.android.com/reference/android/app/Dialog.html#findViewById(int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://developer.android.com/reference/android/app/ActionBar.html!` `https://developer.android.com/reference/android/app/Dialog.html#getActionBar()()` `https://developer.android.com/reference/android/content/Context.html!` `https://developer.android.com/reference/android/app/Dialog.html#getContext()()` `https://developer.android.com/reference/android/view/View.html!` `https://developer.android.com/reference/android/app/Dialog.html#getCurrentFocus()()` `https://developer.android.com/reference/android/view/LayoutInflater.html!` `https://developer.android.com/reference/android/app/Dialog.html#getLayoutInflater()()` `https://developer.android.com/reference/android/window/OnBackInvokedDispatcher.html!` `https://developer.android.com/reference/android/app/Dialog.html#getOnBackInvokedDispatcher()()` `https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/android/app/Dialog.html#getOwnerActivity()()` `https://developer.android.com/reference/android/view/SearchEvent.html!` `https://developer.android.com/reference/android/app/Dialog.html#getSearchEvent()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/app/Dialog.html#getVolumeControlStream()()` `https://developer.android.com/reference/android/view/Window.html!` `https://developer.android.com/reference/android/app/Dialog.html#getWindow()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#hide()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#invalidateOptionsMenu()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#isShowing()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onActionModeFinished(android.view.ActionMode)(mode: https://developer.android.com/reference/android/view/ActionMode.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onActionModeStarted(android.view.ActionMode)(mode: https://developer.android.com/reference/android/view/ActionMode.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onAttachedToWindow()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onBackPressed()()`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onContentChanged()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onContextItemSelected(android.view.MenuItem)(item: https://developer.android.com/reference/android/view/MenuItem.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onContextMenuClosed(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onCreate(android.os.Bundle)(savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)(
menu: https://developer.android.com/reference/android/view/ContextMenu.html!,
v: https://developer.android.com/reference/android/view/View.html!,
menuInfo: https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html!
)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onCreateOptionsMenu(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onCreatePanelMenu(int, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://developer.android.com/reference/android/view/View.html!` `https://developer.android.com/reference/android/app/Dialog.html#onCreatePanelView(int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onDetachedFromWindow()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onGenericMotionEvent(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyLongPress(int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyMultiple(int, int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, repeatCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onKeyShortcut(int, android.view.KeyEvent)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onMenuItemSelected(int, android.view.MenuItem)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, item: https://developer.android.com/reference/android/view/MenuItem.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onMenuOpened(int, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onOptionsItemSelected(android.view.MenuItem)(item: https://developer.android.com/reference/android/view/MenuItem.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onOptionsMenuClosed(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onPanelClosed(int, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onPrepareOptionsMenu(android.view.Menu)(menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onPreparePanel(int, android.view.View, android.view.Menu)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, view: https://developer.android.com/reference/android/view/View.html!, menu: https://developer.android.com/reference/android/view/Menu.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onRestoreInstanceState(android.os.Bundle)(savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html!)` `https://developer.android.com/reference/android/os/Bundle.html!` `https://developer.android.com/reference/android/app/Dialog.html#onSaveInstanceState()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onSearchRequested()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onStart()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onStop()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onTouchEvent(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onTrackballEvent(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onWindowAttributesChanged(android.view.WindowManager.LayoutParams)(params: https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#onWindowFocusChanged(boolean)(hasFocus: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://developer.android.com/reference/android/view/ActionMode.html!` `https://developer.android.com/reference/android/app/Dialog.html#onWindowStartingActionMode(android.view.ActionMode.Callback)(callback: https://developer.android.com/reference/android/view/ActionMode.Callback.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#openContextMenu(android.view.View)(view: https://developer.android.com/reference/android/view/View.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#openOptionsMenu()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#registerForContextMenu(android.view.View)(view: https://developer.android.com/reference/android/view/View.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Dialog.html#requestWindowFeature(int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `T!` `<T : https://developer.android.com/reference/android/view/View.html?> https://developer.android.com/reference/android/app/Dialog.html#requireViewById(int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setCancelMessage(android.os.Message)(msg: https://developer.android.com/reference/android/os/Message.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setCancelable(boolean)(flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setCanceledOnTouchOutside(boolean)(cancel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setContentView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setDismissMessage(android.os.Message)(msg: https://developer.android.com/reference/android/os/Message.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawable(int, android.graphics.drawable.Drawable)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, drawable: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawableAlpha(int, int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawableResource(int, int)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setFeatureDrawableUri(int, android.net.Uri)(featureId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, uri: https://developer.android.com/reference/android/net/Uri.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnCancelListener(android.content.DialogInterface.OnCancelListener)(listener: https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnDismissListener(android.content.DialogInterface.OnDismissListener)(listener: https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnKeyListener(android.content.DialogInterface.OnKeyListener)(onKeyListener: https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOnShowListener(android.content.DialogInterface.OnShowListener)(listener: https://developer.android.com/reference/android/content/DialogInterface.OnShowListener.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setOwnerActivity(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setTitle(int)(titleId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#setVolumeControlStream(int)(streamType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#show()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#takeKeyEvents(boolean)(get: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Dialog.html#unregisterForContextMenu(android.view.View)(view: https://developer.android.com/reference/android/view/View.html!)` From [android.content.DialogInterface](https://developer.android.com/reference/android/content/DialogInterface.html) `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#cancel()()` `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/DialogInterface.html#dismiss()()` From [androidx.lifecycle.LifecycleOwner](https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner) `abstract https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle!` `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner#getLifecycle()()`

The `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle` of this owner.
From [androidx.navigationevent.NavigationEventDispatcherOwner](https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner) `abstract https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher!` `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner#getNavigationEventDispatcher()()`

The `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` that should handle the navigation events.
From [androidx.activity.OnBackPressedDispatcherOwner](https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner) `abstract https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher!` `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner#getOnBackPressedDispatcher()()`

The `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` that should handle the system back button.
From [androidx.savedstate.SavedStateRegistryOwner](https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistryOwner) `abstract https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistry!` `https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistryOwner#getSavedStateRegistry()()`

The `https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistry` owned by this `https://developer.android.com/reference/kotlin/androidx/savedstate/SavedStateRegistryOwner`.
From [android.view.Window.Callback](https://developer.android.com/reference/android/view/Window.Callback.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/view/Window.Callback.html#onPointerCaptureChanged(boolean)(hasCapture: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/view/Window.Callback.html#onProvideKeyboardShortcuts(java.util.List&lt;android.view.KeyboardShortcutGroup&gt;, android.view.Menu, int)(
data: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/KeyboardShortcutGroup.html!>!,
menu: https://developer.android.com/reference/android/view/Menu.html!,
deviceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html
)`

## Protected constructors

### AlertDialog

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
protected AlertDialog(context: Context)
```

### AlertDialog

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
protected AlertDialog(context: Context, themeResId: @StyleRes Int)
```

Construct an AlertDialog that uses an explicit theme. The actual style that an AlertDialog uses is a private implementation, however you can here supply either the name of an attribute in the theme from which to get the dialog's style (such as `https://developer.android.com/reference/kotlin/androidx/appcompat/R.attr#alertDialogTheme()`.

### AlertDialog

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
protected AlertDialog(
    context: Context,
    cancelable: Boolean,
    cancelListener: DialogInterface.OnCancelListener?
)
```

## Public functions

### getButton

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun getButton(whichButton: Int): Button!
```

Gets one of the buttons used in the dialog. Returns null if the specified button does not exist or the dialog has not yet been fully created (for example, via `https://developer.android.com/reference/android/app/Dialog.html#show()` or `https://developer.android.com/reference/android/app/Dialog.html#create()`).

| Parameters |
|---|---|
| `whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The identifier of the button that should be returned. For example, this can be `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/widget/Button.html!` | The button from the dialog, or null if a button does not exist. |

### getListView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun getListView(): ListView!
```

Gets the list view used in the dialog.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/widget/ListView.html!` | The `https://developer.android.com/reference/android/widget/ListView.html` from the dialog. |

### onKeyDown

```
fun onKeyDown(keyCode: Int, event: KeyEvent!): Boolean
```

### onKeyUp

```
fun onKeyUp(keyCode: Int, event: KeyEvent!): Boolean
```

### setButton

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setButton(
    whichButton: Int,
    text: CharSequence!,
    listener: DialogInterface.OnClickListener!
): Unit
```

Sets a listener to be invoked when the positive button of the dialog is pressed. This method has no effect if called after `https://developer.android.com/reference/android/app/Dialog.html#show()`.

| Parameters |
|---|---|
| `whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Which button to set the listener on, can be one of `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE`, `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEGATIVE`, or `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEUTRAL` |
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The text to display in positive button. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

### setButton

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setButton(whichButton: Int, text: CharSequence!, msg: Message!): Unit
```

Sets a message to be sent when a button is pressed. This method has no effect if called after `https://developer.android.com/reference/android/app/Dialog.html#show()`.

| Parameters |
|---|---|
| `whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Which button to set the message for, can be one of `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE`, `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEGATIVE`, or `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEUTRAL` |
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The text to display in positive button. |
| `msg: https://developer.android.com/reference/android/os/Message.html!` | The `https://developer.android.com/reference/android/os/Message.html` to be sent when clicked. |

### setButton

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setButton(
    whichButton: Int,
    text: CharSequence!,
    icon: Drawable!,
    listener: DialogInterface.OnClickListener!
): Unit
```

Sets an icon to be displayed along with the button text and a listener to be invoked when the positive button of the dialog is pressed. This method has no effect if called after `https://developer.android.com/reference/android/app/Dialog.html#show()`.

| Parameters |
|---|---|
| `whichButton: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Which button to set the listener on, can be one of `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE`, `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEGATIVE`, or `https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEUTRAL` |
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The text to display in positive button. |
| `icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!` | The `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` to be set as an icon for the button. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

### setCustomTitle

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setCustomTitle(customTitleView: View!): Unit
```

This method has no effect if called after `https://developer.android.com/reference/android/app/Dialog.html#show()`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setCustomTitle(android.view.View)` |   |

### setIcon

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setIcon(icon: Drawable!): Unit
```

Set the `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` to be used in the title.

| Parameters |
|---|---|
| `icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!` | Drawable to use as the icon or null if you don't want an icon. |

### setIcon

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setIcon(resId: Int): Unit
```

Set resId to 0 if you don't want an icon.

| Parameters |
|---|---|
| `resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the resourceId of the drawable to use as the icon or 0 if you don't want an icon. |

### setIconAttribute

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setIconAttribute(attrId: Int): Unit
```

Sets an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon

| Parameters |
|---|---|
| `attrId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | ID of a theme attribute that points to a drawable resource. |

### setMessage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setMessage(message: CharSequence!): Unit
```

Sets the message to display.

| Parameters |
|---|---|
| `message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The message to display in the dialog. |

### setTitle

```
fun setTitle(title: CharSequence!): Unit
```

### setView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setView(view: View!): Unit
```

Set the view to display in the dialog. This method has no effect if called after `https://developer.android.com/reference/android/app/Dialog.html#show()`.

### setView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
fun setView(
    view: View!,
    viewSpacingLeft: Int,
    viewSpacingTop: Int,
    viewSpacingRight: Int,
    viewSpacingBottom: Int
): Unit
```

Set the view to display in the dialog, specifying the spacing to appear around that view. This method has no effect if called after `https://developer.android.com/reference/android/app/Dialog.html#show()`.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/view/View.html!` | The view to show in the content area of the dialog |
| `viewSpacingLeft: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Extra space to appear to the left of `view` |
| `viewSpacingTop: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Extra space to appear above `view` |
| `viewSpacingRight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Extra space to appear to the right of `view` |
| `viewSpacingBottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Extra space to appear below `view` |

## Protected functions

### onCreate

```
protected fun onCreate(savedInstanceState: Bundle!): Unit
```