# AlertDialog

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/app/AlertDialog#nestedclasses)\|[Constants](https://developer.android.com/reference/android/app/AlertDialog#constants)\|[Inherited Constants](https://developer.android.com/reference/android/app/AlertDialog#inhconstants)\|[Protected Ctors](https://developer.android.com/reference/android/app/AlertDialog#proctors)\|[Methods](https://developer.android.com/reference/android/app/AlertDialog#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/app/AlertDialog#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/app/AlertDialog#inhmethods)  

# AlertDialog

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/app/AlertDialog "View this page in Kotlin")\|Java

`
public


class
AlertDialog
`  
`


``

extends `[Dialog](https://developer.android.com/reference/android/app/Dialog)`


``


implements

`[DialogInterface](https://developer.android.com/reference/android/content/DialogInterface)`


`

|---|---|-------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.app.Dialog](https://developer.android.com/reference/android/app/Dialog) ||
|   | ↳ | android.app.AlertDialog |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog),[ProgressDialog](https://developer.android.com/reference/android/app/ProgressDialog),[TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog) |------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog) | A simple dialog containing an[DatePicker](https://developer.android.com/reference/android/widget/DatePicker).                                                                                                                                                                                                                                                                                                                                                                                     | | [ProgressDialog](https://developer.android.com/reference/android/app/ProgressDialog)     | *This class was deprecated in API level 26.`ProgressDialog`is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like[ProgressBar](https://developer.android.com/reference/android/widget/ProgressBar), which can be embedded in your app's UI. Alternatively, you can use a[notification](https://developer.android.com/guide/topics/ui/notifiers/notifications)to inform the user of the task's progress.* | | [TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog) | A dialog that prompts the user for the time of day using a[TimePicker](https://developer.android.com/reference/android/widget/TimePicker).                                                                                                                                                                                                                                                                                                                                                        | |

<br />

*** ** * ** ***

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:  

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

The AlertDialog class takes care of automatically setting[WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM](https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM)for you based on whether any views in the dialog return true from[View.onCheckIsTextEditor()](https://developer.android.com/reference/android/view/View#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[onCreate(Bundle)](https://developer.android.com/reference/android/app/AlertDialog#onCreate(android.os.Bundle)).  

### Developer Guides

For more information about creating dialogs, read the[Dialogs](https://developer.android.com/guide/topics/ui/dialogs)developer guide.

<br />

## Summary

|                                               ### Nested classes                                                ||
|----------|-------------------------------------------------------------------------------------------------------|
| ` class` | [AlertDialog.Builder](https://developer.android.com/reference/android/app/AlertDialog.Builder) <br /> |

|                                                                                                                                                            ### Constants                                                                                                                                                             ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [THEME_DEVICE_DEFAULT_DARK](https://developer.android.com/reference/android/app/AlertDialog#THEME_DEVICE_DEFAULT_DARK) *This constant was deprecated in API level 23. Use[R.style.Theme_DeviceDefault_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_DeviceDefault_Dialog_Alert).*               |
| `int` | [THEME_DEVICE_DEFAULT_LIGHT](https://developer.android.com/reference/android/app/AlertDialog#THEME_DEVICE_DEFAULT_LIGHT) *This constant was deprecated in API level 23. Use[R.style.Theme_DeviceDefault_Light_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_DeviceDefault_Light_Dialog_Alert).* |
| `int` | [THEME_HOLO_DARK](https://developer.android.com/reference/android/app/AlertDialog#THEME_HOLO_DARK) *This constant was deprecated in API level 23. Use[R.style.Theme_Material_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_Material_Dialog_Alert).*                                             |
| `int` | [THEME_HOLO_LIGHT](https://developer.android.com/reference/android/app/AlertDialog#THEME_HOLO_LIGHT) *This constant was deprecated in API level 23. Use[R.style.Theme_Material_Light_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_Material_Light_Dialog_Alert).*                               |
| `int` | [THEME_TRADITIONAL](https://developer.android.com/reference/android/app/AlertDialog#THEME_TRADITIONAL) *This constant was deprecated in API level 23. Use[R.style.Theme_Material_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_Material_Dialog_Alert).*                                         |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[android.content.DialogInterface](https://developer.android.com/reference/android/content/DialogInterface) |-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [BUTTON1](https://developer.android.com/reference/android/content/DialogInterface#BUTTON1) *This constant was deprecated in API level 15. Use[BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE)* | | `int` | [BUTTON2](https://developer.android.com/reference/android/content/DialogInterface#BUTTON2) *This constant was deprecated in API level 15. Use[BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE)* | | `int` | [BUTTON3](https://developer.android.com/reference/android/content/DialogInterface#BUTTON3) *This constant was deprecated in API level 15. Use[BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL)*   | | `int` | [BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE) The identifier for the negative button.                                                                                                       | | `int` | [BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL) The identifier for the neutral button.                                                                                                          | | `int` | [BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE) The identifier for the positive button.                                                                                                       | |

|                                                                                                                                                                                                                                                             ### Protected constructors                                                                                                                                                                                                                                                              ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[AlertDialog](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context)` context) ` Creates an alert dialog that uses the default alert dialog theme.                                                                                                                                                                                                                                                                |
| ` `[AlertDialog](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context,%20boolean,%20android.content.DialogInterface.OnCancelListener))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, boolean cancelable, `[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener)` cancelListener) ` Creates an alert dialog that uses the default alert dialog theme and a custom cancel listener. |
| ` `[AlertDialog](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context,%20int))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, int themeResId) ` Creates an alert dialog that uses an explicit theme resource.                                                                                                                                                                                                                                             |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                      ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                       ||
|--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Button](https://developer.android.com/reference/android/widget/Button)     | ` `[getButton](https://developer.android.com/reference/android/app/AlertDialog#getButton(int))`(int whichButton) ` Gets one of the buttons used in the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` `[ListView](https://developer.android.com/reference/android/widget/ListView) | ` `[getListView](https://developer.android.com/reference/android/app/AlertDialog#getListView())`() ` Gets the list view used in the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` boolean`                                                                     | ` `[onKeyDown](https://developer.android.com/reference/android/app/AlertDialog#onKeyDown(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` A key was pressed down.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` boolean`                                                                     | ` `[onKeyUp](https://developer.android.com/reference/android/app/AlertDialog#onKeyUp(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` A key was released.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                        | ` `[setButton](https://developer.android.com/reference/android/app/AlertDialog#setButton(java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)` listener) ` *This method was deprecated in API level 15. Use[setButton(int, java.lang.CharSequence, android.content.DialogInterface.OnClickListener)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))with[DialogInterface.BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE)*   |
| ` void`                                                                        | ` `[setButton](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))`(int whichButton, `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)` listener) ` Set a listener to be invoked when the specified button of the dialog is pressed.                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                        | ` `[setButton](https://developer.android.com/reference/android/app/AlertDialog#setButton(java.lang.CharSequence,%20android.os.Message))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Message](https://developer.android.com/reference/android/os/Message)` msg) ` *This method was deprecated in API level 15. Use[setButton(int, java.lang.CharSequence, android.os.Message)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.os.Message))with[DialogInterface.BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE).*                                                                                                                                                   |
| ` void`                                                                        | ` `[setButton](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.os.Message))`(int whichButton, `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Message](https://developer.android.com/reference/android/os/Message)` msg) ` Set a message to be sent when a button is pressed.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`                                                                        | ` `[setButton2](https://developer.android.com/reference/android/app/AlertDialog#setButton2(java.lang.CharSequence,%20android.os.Message))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Message](https://developer.android.com/reference/android/os/Message)` msg) ` *This method was deprecated in API level 15. Use[setButton(int, java.lang.CharSequence, android.os.Message)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.os.Message))with[DialogInterface.BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE).*                                                                                                                                                 |
| ` void`                                                                        | ` `[setButton2](https://developer.android.com/reference/android/app/AlertDialog#setButton2(java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)` listener) ` *This method was deprecated in API level 15. Use[setButton(int, java.lang.CharSequence, android.content.DialogInterface.OnClickListener)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))with[DialogInterface.BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE)* |
| ` void`                                                                        | ` `[setButton3](https://developer.android.com/reference/android/app/AlertDialog#setButton3(java.lang.CharSequence,%20android.os.Message))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Message](https://developer.android.com/reference/android/os/Message)` msg) ` *This method was deprecated in API level 15. Use[setButton(int, java.lang.CharSequence, android.os.Message)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.os.Message))with[DialogInterface.BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL).*                                                                                                                                                   |
| ` void`                                                                        | ` `[setButton3](https://developer.android.com/reference/android/app/AlertDialog#setButton3(java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)` listener) ` *This method was deprecated in API level 15. Use[setButton(int, java.lang.CharSequence, android.content.DialogInterface.OnClickListener)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))with[DialogInterface.BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL)*   |
| ` void`                                                                        | ` `[setCustomTitle](https://developer.android.com/reference/android/app/AlertDialog#setCustomTitle(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` customTitleView) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                        | ` `[setIcon](https://developer.android.com/reference/android/app/AlertDialog#setIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable)` icon) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` void`                                                                        | ` `[setIcon](https://developer.android.com/reference/android/app/AlertDialog#setIcon(int))`(int resId) ` Set resId to 0 if you don't want an icon.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                        | ` `[setIconAttribute](https://developer.android.com/reference/android/app/AlertDialog#setIconAttribute(int))`(int attrId) ` Set an icon as supplied by a theme attribute.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`                                                                        | ` `[setInverseBackgroundForced](https://developer.android.com/reference/android/app/AlertDialog#setInverseBackgroundForced(boolean))`(boolean forceInverseBackground) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                        | ` `[setMessage](https://developer.android.com/reference/android/app/AlertDialog#setMessage(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` message) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` void`                                                                        | ` `[setTitle](https://developer.android.com/reference/android/app/AlertDialog#setTitle(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` title) ` Set the title text for this dialog's window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                        | ` `[setView](https://developer.android.com/reference/android/app/AlertDialog#setView(android.view.View,%20int,%20int,%20int,%20int))`(`[View](https://developer.android.com/reference/android/view/View)` view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom) ` Set the view to display in that dialog, specifying the spacing to appear around that view.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                        | ` `[setView](https://developer.android.com/reference/android/app/AlertDialog#setView(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) ` Set the view to display in that dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

|                                                                                                                                                                                                                                                       ### Protected methods                                                                                                                                                                                                                                                        ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[onCreate](https://developer.android.com/reference/android/app/AlertDialog#onCreate(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` savedInstanceState) ` Similar to[Activity.onCreate](https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)), you should initialize your dialog in this method, including calling[setContentView(View)](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View)). |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.app.Dialog](https://developer.android.com/reference/android/app/Dialog)` ` |--------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                                      | ` `[addContentView](https://developer.android.com/reference/android/app/Dialog#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams)` params) ` Add an additional content view to the screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` void`                                                                                                      | ` `[cancel](https://developer.android.com/reference/android/app/Dialog#cancel())`() ` Cancel the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[closeOptionsMenu](https://developer.android.com/reference/android/app/Dialog#closeOptionsMenu())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                      | ` `[create](https://developer.android.com/reference/android/app/Dialog#create())`() ` Forces immediate creation of the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | ` void`                                                                                                      | ` `[dismiss](https://developer.android.com/reference/android/app/Dialog#dismiss())`() ` Dismiss this dialog, removing it from the screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` boolean`                                                                                                   | ` `[dispatchGenericMotionEvent](https://developer.android.com/reference/android/app/Dialog#dispatchGenericMotionEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` ev) ` Called to process generic motion events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` boolean`                                                                                                   | ` `[dispatchKeyEvent](https://developer.android.com/reference/android/app/Dialog#dispatchKeyEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process key events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                   | ` `[dispatchKeyShortcutEvent](https://developer.android.com/reference/android/app/Dialog#dispatchKeyShortcutEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process a key shortcut event.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | ` boolean`                                                                                                   | ` `[dispatchPopulateAccessibilityEvent](https://developer.android.com/reference/android/app/Dialog#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent))`(`[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)` event) ` Called to process population of[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)s.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | ` boolean`                                                                                                   | ` `[dispatchTouchEvent](https://developer.android.com/reference/android/app/Dialog#dispatchTouchEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` ev) ` Called to process touch screen events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                                   | ` `[dispatchTrackballEvent](https://developer.android.com/reference/android/app/Dialog#dispatchTrackballEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` ev) ` Called to process trackball events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` <T extends `[View](https://developer.android.com/reference/android/view/View)`> T`                         | ` `[findViewById](https://developer.android.com/reference/android/app/Dialog#findViewById(int))`(int id) ` Finds the first descendant view with the given ID or`null`if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via[show()](https://developer.android.com/reference/android/app/Dialog#show())or[create()](https://developer.android.com/reference/android/app/Dialog#create())).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | ` `[ActionBar](https://developer.android.com/reference/android/app/ActionBar)                                | ` `[getActionBar](https://developer.android.com/reference/android/app/Dialog#getActionBar())`() ` Retrieve the[ActionBar](https://developer.android.com/reference/android/app/ActionBar)attached to this dialog, if present.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` final `[Context](https://developer.android.com/reference/android/content/Context)                          | ` `[getContext](https://developer.android.com/reference/android/app/Dialog#getContext())`() ` Retrieve the Context this Dialog is running in.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` `[View](https://developer.android.com/reference/android/view/View)                                         | ` `[getCurrentFocus](https://developer.android.com/reference/android/app/Dialog#getCurrentFocus())`() ` Call[Window.getCurrentFocus()](https://developer.android.com/reference/android/view/Window#getCurrentFocus())on the Window if this Activity to return the currently focused view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` `[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater)                     | ` `[getLayoutInflater](https://developer.android.com/reference/android/app/Dialog#getLayoutInflater())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` `[OnBackInvokedDispatcher](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher) | ` `[getOnBackInvokedDispatcher](https://developer.android.com/reference/android/app/Dialog#getOnBackInvokedDispatcher())`() ` Returns the[OnBackInvokedDispatcher](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher)instance associated with the window that this dialog is attached to.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | ` final `[Activity](https://developer.android.com/reference/android/app/Activity)                            | ` `[getOwnerActivity](https://developer.android.com/reference/android/app/Dialog#getOwnerActivity())`() ` Returns the Activity that owns this Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` final `[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)                     | ` `[getSearchEvent](https://developer.android.com/reference/android/app/Dialog#getSearchEvent())`() ` During the onSearchRequested() callbacks, this function will return the[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)that triggered the callback, if it exists.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | ` final int`                                                                                                 | ` `[getVolumeControlStream](https://developer.android.com/reference/android/app/Dialog#getVolumeControlStream())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` `[Window](https://developer.android.com/reference/android/view/Window)                                     | ` `[getWindow](https://developer.android.com/reference/android/app/Dialog#getWindow())`() ` Retrieve the current Window for the activity.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                      | ` `[hide](https://developer.android.com/reference/android/app/Dialog#hide())`() ` Hide the dialog, but do not dismiss it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                      | ` `[invalidateOptionsMenu](https://developer.android.com/reference/android/app/Dialog#invalidateOptionsMenu())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                                   | ` `[isShowing](https://developer.android.com/reference/android/app/Dialog#isShowing())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` void`                                                                                                      | ` `[onActionModeFinished](https://developer.android.com/reference/android/app/Dialog#onActionModeFinished(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been finished. Note that if you override this method you should always call through to the superclass implementation by calling super.onActionModeFinished(mode).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                      | ` `[onActionModeStarted](https://developer.android.com/reference/android/app/Dialog#onActionModeStarted(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been started. Note that if you override this method you should always call through to the superclass implementation by calling super.onActionModeStarted(mode).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                      | ` `[onAttachedToWindow](https://developer.android.com/reference/android/app/Dialog#onAttachedToWindow())`() ` Called when the window has been attached to the window manager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                      | ` `[onBackPressed](https://developer.android.com/reference/android/app/Dialog#onBackPressed())`() ` *This method was deprecated in API level 33. Use[OnBackInvokedCallback](https://developer.android.com/reference/android/window/OnBackInvokedCallback)or`androidx.activity.OnBackPressedCallback`to handle back navigation instead.* *Starting from Android 13 (API level 33), back event handling is moving to an ahead-of-time model and[onBackPressed()](https://developer.android.com/reference/android/app/Dialog#onBackPressed())and[KeyEvent.KEYCODE_BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)should not be used to handle back events (back gesture or back button click). Instead, an[OnBackInvokedCallback](https://developer.android.com/reference/android/window/OnBackInvokedCallback)should be registered using[Dialog.getOnBackInvokedDispatcher()](https://developer.android.com/reference/android/app/Dialog#getOnBackInvokedDispatcher())[.registerOnBackInvokedCallback(priority, callback)](https://developer.android.com/reference/android/window/OnBackInvokedDispatcher#registerOnBackInvokedCallback(int,%20android.window.OnBackInvokedCallback)).* | | ` void`                                                                                                      | ` `[onContentChanged](https://developer.android.com/reference/android/app/Dialog#onContentChanged())`() ` This hook is called whenever the content view of the screen changes (due to a call to[Window.setContentView](https://developer.android.com/reference/android/view/Window#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))or[Window.addContentView](https://developer.android.com/reference/android/view/Window#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                   | ` `[onContextItemSelected](https://developer.android.com/reference/android/app/Dialog#onContextItemSelected(android.view.MenuItem))`(`[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[onContextMenuClosed](https://developer.android.com/reference/android/app/Dialog#onContextMenuClosed(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[onCreate](https://developer.android.com/reference/android/app/Dialog#onCreate(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` savedInstanceState) ` Similar to[Activity.onCreate](https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)), you should initialize your dialog in this method, including calling[setContentView(View)](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                      | ` `[onCreateContextMenu](https://developer.android.com/reference/android/app/Dialog#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo))`(`[ContextMenu](https://developer.android.com/reference/android/view/ContextMenu)` menu, `[View](https://developer.android.com/reference/android/view/View)` v, `[ContextMenu.ContextMenuInfo](https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo)` menuInfo) ` Called when the context menu for this view is being built.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` boolean`                                                                                                   | ` `[onCreateOptionsMenu](https://developer.android.com/reference/android/app/Dialog#onCreateOptionsMenu(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` It is usually safe to proxy this call to the owner activity's[Activity.onCreateOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onCreateOptionsMenu(android.view.Menu))if the client desires the same menu for this Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                                   | ` `[onCreatePanelMenu](https://developer.android.com/reference/android/app/Dialog#onCreatePanelMenu(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Initialize the contents of the menu for panel 'featureId'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` `[View](https://developer.android.com/reference/android/view/View)                                         | ` `[onCreatePanelView](https://developer.android.com/reference/android/app/Dialog#onCreatePanelView(int))`(int featureId) ` Instantiate the view to display in the panel for 'featureId'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                      | ` `[onDetachedFromWindow](https://developer.android.com/reference/android/app/Dialog#onDetachedFromWindow())`() ` Called when the window has been detached from the window manager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                                   | ` `[onGenericMotionEvent](https://developer.android.com/reference/android/app/Dialog#onGenericMotionEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called when a generic motion event was not handled by any of the views inside of the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                   | ` `[onKeyDown](https://developer.android.com/reference/android/app/Dialog#onKeyDown(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` A key was pressed down.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                   | ` `[onKeyLongPress](https://developer.android.com/reference/android/app/Dialog#onKeyLongPress(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Default implementation of[KeyEvent.Callback.onKeyLongPress()](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                   | ` `[onKeyMultiple](https://developer.android.com/reference/android/app/Dialog#onKeyMultiple(int,%20int,%20android.view.KeyEvent))`(int keyCode, int repeatCount, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Default implementation of[KeyEvent.Callback.onKeyMultiple()](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                                   | ` `[onKeyShortcut](https://developer.android.com/reference/android/app/Dialog#onKeyShortcut(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a key shortcut event is not handled by any of the views in the Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                                   | ` `[onKeyUp](https://developer.android.com/reference/android/app/Dialog#onKeyUp(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` A key was released.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` boolean`                                                                                                   | ` `[onMenuItemSelected](https://developer.android.com/reference/android/app/Dialog#onMenuItemSelected(int,%20android.view.MenuItem))`(int featureId, `[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) ` Called when a panel's menu item has been selected by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | ` boolean`                                                                                                   | ` `[onMenuOpened](https://developer.android.com/reference/android/app/Dialog#onMenuOpened(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel's menu is opened by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` boolean`                                                                                                   | ` `[onOptionsItemSelected](https://developer.android.com/reference/android/app/Dialog#onOptionsItemSelected(android.view.MenuItem))`(`[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[onOptionsMenuClosed](https://developer.android.com/reference/android/app/Dialog#onOptionsMenuClosed(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[onPanelClosed](https://developer.android.com/reference/android/app/Dialog#onPanelClosed(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel is being closed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | ` boolean`                                                                                                   | ` `[onPrepareOptionsMenu](https://developer.android.com/reference/android/app/Dialog#onPrepareOptionsMenu(android.view.Menu))`(`[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` It is usually safe to proxy this call to the owner activity's[Activity.onPrepareOptionsMenu(Menu)](https://developer.android.com/reference/android/app/Activity#onPrepareOptionsMenu(android.view.Menu))if the client desires the same menu for this Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | ` boolean`                                                                                                   | ` `[onPreparePanel](https://developer.android.com/reference/android/app/Dialog#onPreparePanel(int,%20android.view.View,%20android.view.Menu))`(int featureId, `[View](https://developer.android.com/reference/android/view/View)` view, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Prepare a panel to be displayed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                      | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/app/Dialog#onRestoreInstanceState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` savedInstanceState) ` Restore the state of the dialog from a previously saved bundle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle)                                       | ` `[onSaveInstanceState](https://developer.android.com/reference/android/app/Dialog#onSaveInstanceState())`() ` Saves the state of the dialog into a bundle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` boolean`                                                                                                   | ` `[onSearchRequested](https://developer.android.com/reference/android/app/Dialog#onSearchRequested(android.view.SearchEvent))`(`[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)` searchEvent) ` This hook is called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` boolean`                                                                                                   | ` `[onSearchRequested](https://developer.android.com/reference/android/app/Dialog#onSearchRequested())`() ` This hook is called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` void`                                                                                                      | ` `[onStart](https://developer.android.com/reference/android/app/Dialog#onStart())`() ` Called when the dialog is starting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` void`                                                                                                      | ` `[onStop](https://developer.android.com/reference/android/app/Dialog#onStop())`() ` Called to tell you that you're stopping.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | ` boolean`                                                                                                   | ` `[onTouchEvent](https://developer.android.com/reference/android/app/Dialog#onTouchEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called when a touch screen event was not handled by any of the views under it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                                   | ` `[onTrackballEvent](https://developer.android.com/reference/android/app/Dialog#onTrackballEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called when the trackball was moved and not handled by any of the views inside of the activity.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[onWindowAttributesChanged](https://developer.android.com/reference/android/app/Dialog#onWindowAttributesChanged(android.view.WindowManager.LayoutParams))`(`[WindowManager.LayoutParams](https://developer.android.com/reference/android/view/WindowManager.LayoutParams)` params) ` This is called whenever the current window attributes change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                                      | ` `[onWindowFocusChanged](https://developer.android.com/reference/android/app/Dialog#onWindowFocusChanged(boolean))`(boolean hasFocus) ` This hook is called whenever the window focus changes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | ` `[ActionMode](https://developer.android.com/reference/android/view/ActionMode)                             | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/app/Dialog#onWindowStartingActionMode(android.view.ActionMode.Callback))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback) ` Called when an action mode is being started for this window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` `[ActionMode](https://developer.android.com/reference/android/view/ActionMode)                             | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/app/Dialog#onWindowStartingActionMode(android.view.ActionMode.Callback,%20int))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback, int type) ` Called when an action mode is being started for this window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                      | ` `[openContextMenu](https://developer.android.com/reference/android/app/Dialog#openContextMenu(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                      | ` `[openOptionsMenu](https://developer.android.com/reference/android/app/Dialog#openOptionsMenu())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | ` void`                                                                                                      | ` `[registerForContextMenu](https://developer.android.com/reference/android/app/Dialog#registerForContextMenu(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | ` final boolean`                                                                                             | ` `[requestWindowFeature](https://developer.android.com/reference/android/app/Dialog#requestWindowFeature(int))`(int featureId) ` Enable extended window features.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` final <T extends `[View](https://developer.android.com/reference/android/view/View)`> T`                   | ` `[requireViewById](https://developer.android.com/reference/android/app/Dialog#requireViewById(int))`(int id) ` Finds the first descendant view with the given ID or throws an IllegalArgumentException if the ID is invalid (\< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via[show()](https://developer.android.com/reference/android/app/Dialog#show())or[create()](https://developer.android.com/reference/android/app/Dialog#create())).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | ` void`                                                                                                      | ` `[setCancelMessage](https://developer.android.com/reference/android/app/Dialog#setCancelMessage(android.os.Message))`(`[Message](https://developer.android.com/reference/android/os/Message)` msg) ` Set a message to be sent when the dialog is canceled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                      | ` `[setCancelable](https://developer.android.com/reference/android/app/Dialog#setCancelable(boolean))`(boolean flag) ` Sets whether this dialog is cancelable with the[BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                      | ` `[setCanceledOnTouchOutside](https://developer.android.com/reference/android/app/Dialog#setCanceledOnTouchOutside(boolean))`(boolean cancel) ` Sets whether this dialog is canceled when touched outside the window's bounds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                      | ` `[setContentView](https://developer.android.com/reference/android/app/Dialog#setContentView(int))`(int layoutResID) ` Set the screen content from a layout resource.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                                      | ` `[setContentView](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams)` params) ` Set the screen content to an explicit view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                                      | ` `[setContentView](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) ` Set the screen content to an explicit view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                                      | ` `[setDismissMessage](https://developer.android.com/reference/android/app/Dialog#setDismissMessage(android.os.Message))`(`[Message](https://developer.android.com/reference/android/os/Message)` msg) ` Set a message to be sent when the dialog is dismissed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | ` final void`                                                                                                | ` `[setFeatureDrawable](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawable(int,%20android.graphics.drawable.Drawable))`(int featureId, `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable)` drawable) ` Convenience for calling[Window.setFeatureDrawable(int, Drawable)](https://developer.android.com/reference/android/view/Window#setFeatureDrawable(int,%20android.graphics.drawable.Drawable)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` final void`                                                                                                | ` `[setFeatureDrawableAlpha](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawableAlpha(int,%20int))`(int featureId, int alpha) ` Convenience for calling[Window.setFeatureDrawableAlpha(int, int)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableAlpha(int,%20int)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | ` final void`                                                                                                | ` `[setFeatureDrawableResource](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawableResource(int,%20int))`(int featureId, int resId) ` Convenience for calling[Window.setFeatureDrawableResource(int, int)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableResource(int,%20int)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` final void`                                                                                                | ` `[setFeatureDrawableUri](https://developer.android.com/reference/android/app/Dialog#setFeatureDrawableUri(int,%20android.net.Uri))`(int featureId, `[Uri](https://developer.android.com/reference/android/net/Uri)` uri) ` Convenience for calling[Window.setFeatureDrawableUri(int, Uri)](https://developer.android.com/reference/android/view/Window#setFeatureDrawableUri(int,%20android.net.Uri)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[setOnCancelListener](https://developer.android.com/reference/android/app/Dialog#setOnCancelListener(android.content.DialogInterface.OnCancelListener))`(`[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener)` listener) ` Set a listener to be invoked when the dialog is canceled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                      | ` `[setOnDismissListener](https://developer.android.com/reference/android/app/Dialog#setOnDismissListener(android.content.DialogInterface.OnDismissListener))`(`[DialogInterface.OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener)` listener) ` Set a listener to be invoked when the dialog is dismissed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                                      | ` `[setOnKeyListener](https://developer.android.com/reference/android/app/Dialog#setOnKeyListener(android.content.DialogInterface.OnKeyListener))`(`[DialogInterface.OnKeyListener](https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener)` onKeyListener) ` Sets the callback that will be called if a key is dispatched to the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                      | ` `[setOnShowListener](https://developer.android.com/reference/android/app/Dialog#setOnShowListener(android.content.DialogInterface.OnShowListener))`(`[DialogInterface.OnShowListener](https://developer.android.com/reference/android/content/DialogInterface.OnShowListener)` listener) ` Sets a listener to be invoked when the dialog is shown.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` final void`                                                                                                | ` `[setOwnerActivity](https://developer.android.com/reference/android/app/Dialog#setOwnerActivity(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity)` activity) ` Sets the Activity that owns this dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                      | ` `[setTitle](https://developer.android.com/reference/android/app/Dialog#setTitle(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` title) ` Set the title text for this dialog's window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` void`                                                                                                      | ` `[setTitle](https://developer.android.com/reference/android/app/Dialog#setTitle(int))`(int titleId) ` Set the title text for this dialog's window.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` final void`                                                                                                | ` `[setVolumeControlStream](https://developer.android.com/reference/android/app/Dialog#setVolumeControlStream(int))`(int streamType) ` By default, this will use the owner Activity's suggested stream type.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                      | ` `[show](https://developer.android.com/reference/android/app/Dialog#show())`() ` Start the dialog and display it on screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                      | ` `[takeKeyEvents](https://developer.android.com/reference/android/app/Dialog#takeKeyEvents(boolean))`(boolean get) ` Request that key events come to this dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` void`                                                                                                      | ` `[unregisterForContextMenu](https://developer.android.com/reference/android/app/Dialog#unregisterForContextMenu(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` view) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.content.DialogInterface](https://developer.android.com/reference/android/content/DialogInterface)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[cancel](https://developer.android.com/reference/android/content/DialogInterface#cancel())`() ` Cancels the dialog, invoking the[OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener).       | | ` abstract void` | ` `[dismiss](https://developer.android.com/reference/android/content/DialogInterface#dismiss())`() ` Dismisses the dialog, invoking the[OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener). | ||
| From interface` `[android.view.KeyEvent.Callback](https://developer.android.com/reference/android/view/KeyEvent.Callback)` ` |---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean` | ` `[onKeyDown](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyDown(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a key down event has occurred.                                                                                                                                                               | | ` abstract boolean` | ` `[onKeyLongPress](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a long press has occurred.                                                                                                                                                         | | ` abstract boolean` | ` `[onKeyMultiple](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent))`(int keyCode, int count, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a user's interaction with an analog control, such as flinging a trackball, generates simulated down/up events for the same key multiple times in quick succession. | | ` abstract boolean` | ` `[onKeyUp](https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyUp(int,%20android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called when a key up event has occurred.                                                                                                                                                                     | ||
| From interface` `[android.view.View.OnCreateContextMenuListener](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener)` ` |------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[onCreateContextMenu](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo))`(`[ContextMenu](https://developer.android.com/reference/android/view/ContextMenu)` menu, `[View](https://developer.android.com/reference/android/view/View)` v, `[ContextMenu.ContextMenuInfo](https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo)` menuInfo) ` Called when the context menu for this view is being built. | ||
| From interface` `[android.view.Window.Callback](https://developer.android.com/reference/android/view/Window.Callback)` ` |-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                                       | ` `[dispatchGenericMotionEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchGenericMotionEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called to process generic motion events.                                                                                                                                                                                                                                                                | | ` abstract boolean`                                                                       | ` `[dispatchKeyEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchKeyEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process key events.                                                                                                                                                                                                                                                                                                        | | ` abstract boolean`                                                                       | ` `[dispatchKeyShortcutEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchKeyShortcutEvent(android.view.KeyEvent))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Called to process a key shortcut event.                                                                                                                                                                                                                                                                              | | ` abstract boolean`                                                                       | ` `[dispatchPopulateAccessibilityEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent))`(`[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)` event) ` Called to process population of[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent)s.                                                                                           | | ` abstract boolean`                                                                       | ` `[dispatchTouchEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchTouchEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called to process touch screen events.                                                                                                                                                                                                                                                                                  | | ` abstract boolean`                                                                       | ` `[dispatchTrackballEvent](https://developer.android.com/reference/android/view/Window.Callback#dispatchTrackballEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)` event) ` Called to process trackball events.                                                                                                                                                                                                                                                                             | | ` abstract void`                                                                          | ` `[onActionModeFinished](https://developer.android.com/reference/android/view/Window.Callback#onActionModeFinished(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been finished.                                                                                                                                                                                                                                                                           | | ` abstract void`                                                                          | ` `[onActionModeStarted](https://developer.android.com/reference/android/view/Window.Callback#onActionModeStarted(android.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode)` mode) ` Called when an action mode has been started.                                                                                                                                                                                                                                                                              | | ` abstract void`                                                                          | ` `[onAttachedToWindow](https://developer.android.com/reference/android/view/Window.Callback#onAttachedToWindow())`() ` Called when the window has been attached to the window manager.                                                                                                                                                                                                                                                                                                                                                                        | | ` abstract void`                                                                          | ` `[onContentChanged](https://developer.android.com/reference/android/view/Window.Callback#onContentChanged())`() ` This hook is called whenever the content view of the screen changes (due to a call to[Window.setContentView](https://developer.android.com/reference/android/view/Window#setContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))or[Window.addContentView](https://developer.android.com/reference/android/view/Window#addContentView(android.view.View,%20android.view.ViewGroup.LayoutParams))).                        | | ` abstract boolean`                                                                       | ` `[onCreatePanelMenu](https://developer.android.com/reference/android/view/Window.Callback#onCreatePanelMenu(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Initialize the contents of the menu for panel 'featureId'.                                                                                                                                                                                                                                                                | | ` abstract `[View](https://developer.android.com/reference/android/view/View)             | ` `[onCreatePanelView](https://developer.android.com/reference/android/view/Window.Callback#onCreatePanelView(int))`(int featureId) ` Instantiate the view to display in the panel for 'featureId'.                                                                                                                                                                                                                                                                                                                                                            | | ` abstract void`                                                                          | ` `[onDetachedFromWindow](https://developer.android.com/reference/android/view/Window.Callback#onDetachedFromWindow())`() ` Called when the window has been detached from the window manager.                                                                                                                                                                                                                                                                                                                                                                  | | ` abstract boolean`                                                                       | ` `[onMenuItemSelected](https://developer.android.com/reference/android/view/Window.Callback#onMenuItemSelected(int,%20android.view.MenuItem))`(int featureId, `[MenuItem](https://developer.android.com/reference/android/view/MenuItem)` item) ` Called when a panel's menu item has been selected by the user.                                                                                                                                                                                                                                              | | ` abstract boolean`                                                                       | ` `[onMenuOpened](https://developer.android.com/reference/android/view/Window.Callback#onMenuOpened(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel's menu is opened by the user.                                                                                                                                                                                                                                                                                   | | ` abstract void`                                                                          | ` `[onPanelClosed](https://developer.android.com/reference/android/view/Window.Callback#onPanelClosed(int,%20android.view.Menu))`(int featureId, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Called when a panel is being closed.                                                                                                                                                                                                                                                                                              | | ` default void`                                                                           | ` `[onPointerCaptureChanged](https://developer.android.com/reference/android/view/Window.Callback#onPointerCaptureChanged(boolean))`(boolean hasCapture) ` Called when pointer capture is enabled or disabled for the current window.                                                                                                                                                                                                                                                                                                                          | | ` abstract boolean`                                                                       | ` `[onPreparePanel](https://developer.android.com/reference/android/view/Window.Callback#onPreparePanel(int,%20android.view.View,%20android.view.Menu))`(int featureId, `[View](https://developer.android.com/reference/android/view/View)` view, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu) ` Prepare a panel to be displayed.                                                                                                                                                                                                 | | ` default void`                                                                           | ` `[onProvideKeyboardShortcuts](https://developer.android.com/reference/android/view/Window.Callback#onProvideKeyboardShortcuts(java.util.List<android.view.KeyboardShortcutGroup>,%20android.view.Menu,%20int))`(`[List](https://developer.android.com/reference/java/util/List)`<`[KeyboardShortcutGroup](https://developer.android.com/reference/android/view/KeyboardShortcutGroup)`> data, `[Menu](https://developer.android.com/reference/android/view/Menu)` menu, int deviceId) ` Called when Keyboard Shortcuts are requested for the current window. | | ` abstract boolean`                                                                       | ` `[onSearchRequested](https://developer.android.com/reference/android/view/Window.Callback#onSearchRequested())`() ` Called when the user signals the desire to start a search.                                                                                                                                                                                                                                                                                                                                                                               | | ` abstract boolean`                                                                       | ` `[onSearchRequested](https://developer.android.com/reference/android/view/Window.Callback#onSearchRequested(android.view.SearchEvent))`(`[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent)` searchEvent) ` Called when the user signals the desire to start a search.                                                                                                                                                                                                                                                          | | ` abstract void`                                                                          | ` `[onWindowAttributesChanged](https://developer.android.com/reference/android/view/Window.Callback#onWindowAttributesChanged(android.view.WindowManager.LayoutParams))`(`[WindowManager.LayoutParams](https://developer.android.com/reference/android/view/WindowManager.LayoutParams)` attrs) ` This is called whenever the current window attributes change.                                                                                                                                                                                                | | ` abstract void`                                                                          | ` `[onWindowFocusChanged](https://developer.android.com/reference/android/view/Window.Callback#onWindowFocusChanged(boolean))`(boolean hasFocus) ` This hook is called whenever the window focus changes.                                                                                                                                                                                                                                                                                                                                                      | | ` abstract `[ActionMode](https://developer.android.com/reference/android/view/ActionMode) | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback) ` Called when an action mode is being started for this window.                                                                                                                                                                                                                 | | ` abstract `[ActionMode](https://developer.android.com/reference/android/view/ActionMode) | ` `[onWindowStartingActionMode](https://developer.android.com/reference/android/view/Window.Callback#onWindowStartingActionMode(android.view.ActionMode.Callback,%20int))`(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback)` callback, int type) ` Called when an action mode is being started for this window.                                                                                                                                                                                                | ||

## Constants

### THEME_DEVICE_DEFAULT_DARK

Added in[API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int THEME_DEVICE_DEFAULT_DARK
```

<br />

**This constant was deprecated in API level 23.**   
Use[R.style.Theme_DeviceDefault_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_DeviceDefault_Dialog_Alert).

Special theme constant for[AlertDialog(android.content.Context, int)](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context,%20int)): use the device's default alert theme with a dark background.

<br />

Constant Value: 4 (0x00000004)  

### THEME_DEVICE_DEFAULT_LIGHT

Added in[API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int THEME_DEVICE_DEFAULT_LIGHT
```

<br />

**This constant was deprecated in API level 23.**   
Use[R.style.Theme_DeviceDefault_Light_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_DeviceDefault_Light_Dialog_Alert).

Special theme constant for[AlertDialog(android.content.Context, int)](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context,%20int)): use the device's default alert theme with a light background.

<br />

Constant Value: 5 (0x00000005)  

### THEME_HOLO_DARK

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int THEME_HOLO_DARK
```

<br />

**This constant was deprecated in API level 23.**   
Use[R.style.Theme_Material_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_Material_Dialog_Alert).

Special theme constant for[AlertDialog(android.content.Context, int)](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context,%20int)): use the holographic alert theme with a dark background.

<br />

Constant Value: 2 (0x00000002)  

### THEME_HOLO_LIGHT

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int THEME_HOLO_LIGHT
```

<br />

**This constant was deprecated in API level 23.**   
Use[R.style.Theme_Material_Light_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_Material_Light_Dialog_Alert).

Special theme constant for[AlertDialog(android.content.Context, int)](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context,%20int)): use the holographic alert theme with a light background.

<br />

Constant Value: 3 (0x00000003)  

### THEME_TRADITIONAL

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int THEME_TRADITIONAL
```

<br />

**This constant was deprecated in API level 23.**   
Use[R.style.Theme_Material_Dialog_Alert](https://developer.android.com/reference/android/R.style#Theme_Material_Dialog_Alert).

Special theme constant for[AlertDialog(android.content.Context, int)](https://developer.android.com/reference/android/app/AlertDialog#AlertDialog(android.content.Context,%20int)): use the traditional (pre-Holo) alert dialog theme.

<br />

Constant Value: 1 (0x00000001)

## Protected constructors

### AlertDialog

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

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

Creates an alert dialog that uses the default alert dialog theme.

The default alert dialog theme is defined by[R.attr.alertDialogTheme](https://developer.android.com/reference/android/R.attr#alertDialogTheme)within the parent`context`'s theme.

<br />

|                   Parameters                    ||
|-----------|--------------------------------------|
| `context` | `Context`: the parent context <br /> |

**See also:**

- [R.styleable.Theme_alertDialogTheme](https://developer.android.com/reference/android/R.styleable#Theme_alertDialogTheme)  

### AlertDialog

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected AlertDialog (Context context, 
                boolean cancelable, 
                DialogInterface.OnCancelListener cancelListener)
```

Creates an alert dialog that uses the default alert dialog theme and a custom cancel listener.

This is functionally identical to:  

```
     AlertDialog dialog = new AlertDialog(context);
     alertDialog.setCancelable(cancelable);
     alertDialog.setOnCancelListener(cancelListener);
 
```

The default alert dialog theme is defined by[R.attr.alertDialogTheme](https://developer.android.com/reference/android/R.attr#alertDialogTheme)within the parent`context`'s theme.

<br />

|                         Parameters                          ||
|------------------|-------------------------------------------|
| `context`        | `Context`: the parent context <br />      |
| `cancelable`     | `boolean` <br />                          |
| `cancelListener` | `DialogInterface.OnCancelListener` <br /> |

**See also:**

- [R.styleable.Theme_alertDialogTheme](https://developer.android.com/reference/android/R.styleable#Theme_alertDialogTheme)  

### AlertDialog

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected AlertDialog (Context context, 
                int themeResId)
```

Creates an alert dialog that uses an explicit theme resource.

The specified theme resource (`themeResId`) is applied on top of the parent`context`'s theme. It may be specified as a style resource containing a fully-populated theme, such as[R.style.Theme_Material_Dialog](https://developer.android.com/reference/android/R.style#Theme_Material_Dialog), to replace all attributes in the parent`context`'s theme including primary and accent colors.

To preserve attributes such as primary and accent colors, the`themeResId`may instead be specified as an overlay theme such as[R.style.ThemeOverlay_Material_Dialog](https://developer.android.com/reference/android/R.style#ThemeOverlay_Material_Dialog). This will override only the window attributes necessary to style the alert window as a dialog.

Alternatively, the`themeResId`may be specified as`0`to use the parent`context`'s resolved value for[R.attr.alertDialogTheme](https://developer.android.com/reference/android/R.attr#alertDialogTheme).

<br />

|                                                                         Parameters                                                                          ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `context`    | `Context`: the parent context <br />                                                                                                          |
| `themeResId` | `int`: the resource ID of the theme against which to inflate this dialog, or`0`to use the parent`context`'s default alert dialog theme <br /> |

**See also:**

- [R.styleable.Theme_alertDialogTheme](https://developer.android.com/reference/android/R.styleable#Theme_alertDialogTheme)

## Public methods

### getButton

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Button getButton (int whichButton)
```

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[Dialog.show()](https://developer.android.com/reference/android/app/Dialog#show())or[Dialog.create()](https://developer.android.com/reference/android/app/Dialog#create())).

<br />

|                                                                                                               Parameters                                                                                                               ||
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `whichButton` | `int`: The identifier of the button that should be returned. For example, this can be[DialogInterface.BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE). <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Button](https://developer.android.com/reference/android/widget/Button) | The button from the dialog, or null if a button does not exist. <br /> |

### getListView

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public ListView getListView ()
```

Gets the list view used in the dialog.

<br />

|                                                                                      Returns                                                                                       ||
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
| [ListView](https://developer.android.com/reference/android/widget/ListView) | The[ListView](https://developer.android.com/reference/android/widget/ListView)from the dialog. <br /> |

### onKeyDown

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean onKeyDown (int keyCode, 
                KeyEvent event)
```

A key was pressed down.

If the focused view didn't want this event, this method is called.

Default implementation consumes[KEYCODE_BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)and, as of[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES#P),[KEYCODE_ESCAPE](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_ESCAPE)to later handle them in[onKeyUp(int, KeyEvent)](https://developer.android.com/reference/android/app/Dialog#onKeyUp(int,%20android.view.KeyEvent)).

<br />

|                        Parameters                         ||
|-----------|------------------------------------------------|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event`   | `KeyEvent`: This value cannot be`null`. <br /> |

|                                                                  Returns                                                                  ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. <br /> |

### onKeyUp

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean onKeyUp (int keyCode, 
                KeyEvent event)
```

A key was released.

Default implementation consumes[KEYCODE_BACK](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK)and, as of[P](https://developer.android.com/reference/android/os/Build.VERSION_CODES#P),[KEYCODE_ESCAPE](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_ESCAPE)to close the dialog.

<br />

|                        Parameters                         ||
|-----------|------------------------------------------------|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event`   | `KeyEvent`: This value cannot be`null`. <br /> |

|                                                                  Returns                                                                  ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false. <br /> |

### setButton

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton (CharSequence text, 
                DialogInterface.OnClickListener listener)
```

<br />

**This method was deprecated in API level 15.**   
Use[setButton(int, java.lang.CharSequence, android.content.DialogInterface.OnClickListener)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))with[DialogInterface.BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE)

Set a listener to be invoked when button 1 of the dialog is pressed.

<br />

|                                                                                         Parameters                                                                                         ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text`     | `CharSequence`: The text to display in button 1. <br />                                                                                                                        |
| `listener` | `DialogInterface.OnClickListener`: The[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)to use. <br /> |

### setButton

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton (int whichButton, 
                CharSequence text, 
                DialogInterface.OnClickListener listener)
```

Set a listener to be invoked when the specified button of the dialog is pressed.

<br />

|                                                                                                                                                                                                                            Parameters                                                                                                                                                                                                                            ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `whichButton` | `int`: Which button to set the listener on, can be one of[DialogInterface.BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE),[DialogInterface.BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE), or[DialogInterface.BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL) <br /> |
| `text`        | `CharSequence`: The text to display in positive button. <br />                                                                                                                                                                                                                                                                                                                                                                                    |
| `listener`    | `DialogInterface.OnClickListener`: The[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)to use. <br />                                                                                                                                                                                                                                                                    |

### setButton

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton (CharSequence text, 
                Message msg)
```

<br />

**This method was deprecated in API level 15.**   
Use[setButton(int, java.lang.CharSequence, android.os.Message)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.os.Message))with[DialogInterface.BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE).

<br />

<br />

|          Parameters           ||
|--------|-----------------------|
| `text` | `CharSequence` <br /> |
| `msg`  | `Message` <br />      |

### setButton

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton (int whichButton, 
                CharSequence text, 
                Message msg)
```

Set a message to be sent when a button is pressed.

<br />

|                                                                                                                                                                                                                            Parameters                                                                                                                                                                                                                            ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `whichButton` | `int`: Which button to set the message for, can be one of[DialogInterface.BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE),[DialogInterface.BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE), or[DialogInterface.BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL) <br /> |
| `text`        | `CharSequence`: The text to display in positive button. <br />                                                                                                                                                                                                                                                                                                                                                                                    |
| `msg`         | `Message`: The[Message](https://developer.android.com/reference/android/os/Message)to be sent when clicked. <br />                                                                                                                                                                                                                                                                                                                                |

### setButton2

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton2 (CharSequence text, 
                Message msg)
```

<br />

**This method was deprecated in API level 15.**   
Use[setButton(int, java.lang.CharSequence, android.os.Message)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.os.Message))with[DialogInterface.BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE).

<br />

<br />

|          Parameters           ||
|--------|-----------------------|
| `text` | `CharSequence` <br /> |
| `msg`  | `Message` <br />      |

### setButton2

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton2 (CharSequence text, 
                DialogInterface.OnClickListener listener)
```

<br />

**This method was deprecated in API level 15.**   
Use[setButton(int, java.lang.CharSequence, android.content.DialogInterface.OnClickListener)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))with[DialogInterface.BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEGATIVE)

Set a listener to be invoked when button 2 of the dialog is pressed.

<br />

|                                                                                         Parameters                                                                                         ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text`     | `CharSequence`: The text to display in button 2. <br />                                                                                                                        |
| `listener` | `DialogInterface.OnClickListener`: The[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)to use. <br /> |

### setButton3

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton3 (CharSequence text, 
                Message msg)
```

<br />

**This method was deprecated in API level 15.**   
Use[setButton(int, java.lang.CharSequence, android.os.Message)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.os.Message))with[DialogInterface.BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL).

<br />

<br />

|          Parameters           ||
|--------|-----------------------|
| `text` | `CharSequence` <br /> |
| `msg`  | `Message` <br />      |

### setButton3

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setButton3 (CharSequence text, 
                DialogInterface.OnClickListener listener)
```

<br />

**This method was deprecated in API level 15.**   
Use[setButton(int, java.lang.CharSequence, android.content.DialogInterface.OnClickListener)](https://developer.android.com/reference/android/app/AlertDialog#setButton(int,%20java.lang.CharSequence,%20android.content.DialogInterface.OnClickListener))with[DialogInterface.BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface#BUTTON_NEUTRAL)

Set a listener to be invoked when button 3 of the dialog is pressed.

<br />

|                                                                                         Parameters                                                                                         ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text`     | `CharSequence`: The text to display in button 3. <br />                                                                                                                        |
| `listener` | `DialogInterface.OnClickListener`: The[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener)to use. <br /> |

### setCustomTitle

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setCustomTitle (View customTitleView)
```

<br />

<br />

|            Parameters            ||
|-------------------|---------------|
| `customTitleView` | `View` <br /> |

**See also:**

- [AlertDialog.Builder.setCustomTitle(View)](https://developer.android.com/reference/android/app/AlertDialog.Builder#setCustomTitle(android.view.View))  

### setIcon

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setIcon (Drawable icon)
```

<br />

<br />

|        Parameters         ||
|--------|-------------------|
| `icon` | `Drawable` <br /> |

### setIcon

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setIcon (int resId)
```

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

<br />

|                                                Parameters                                                ||
|---------|-------------------------------------------------------------------------------------------------|
| `resId` | `int`: the resourceId of the drawable to use as the icon or 0 if you don't want an icon. <br /> |

### setIconAttribute

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setIconAttribute (int attrId)
```

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

<br />

|                                     Parameters                                      ||
|----------|---------------------------------------------------------------------------|
| `attrId` | `int`: ID of a theme attribute that points to a drawable resource. <br /> |

### setInverseBackgroundForced

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setInverseBackgroundForced (boolean forceInverseBackground)
```

<br />

<br />

|                 Parameters                 ||
|--------------------------|------------------|
| `forceInverseBackground` | `boolean` <br /> |

### setMessage

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setMessage (CharSequence message)
```

<br />

<br />

|            Parameters            ||
|-----------|-----------------------|
| `message` | `CharSequence` <br /> |

### setTitle

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setTitle (CharSequence title)
```

Set the title text for this dialog's window.

<br />

|                                           Parameters                                           ||
|---------|---------------------------------------------------------------------------------------|
| `title` | `CharSequence`: The new text to display in the title. This value may be`null`. <br /> |

### setView

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setView (View view, 
                int viewSpacingLeft, 
                int viewSpacingTop, 
                int viewSpacingRight, 
                int viewSpacingBottom)
```

Set the view to display in that dialog, specifying the spacing to appear around that view.

<br />

|                                       Parameters                                       ||
|---------------------|-------------------------------------------------------------------|
| `view`              | `View`: The view to show in the content area of the dialog <br /> |
| `viewSpacingLeft`   | `int`: Extra space to appear to the left of`view` <br />          |
| `viewSpacingTop`    | `int`: Extra space to appear above`view` <br />                   |
| `viewSpacingRight`  | `int`: Extra space to appear to the right of`view` <br />         |
| `viewSpacingBottom` | `int`: Extra space to appear below`view` <br />                   |

### setView

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setView (View view)
```

Set the view to display in that dialog.

<br />

|      Parameters       ||
|--------|---------------|
| `view` | `View` <br /> |

## Protected methods

### onCreate

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected void onCreate (Bundle savedInstanceState)
```

Similar to[Activity.onCreate](https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)), you should initialize your dialog in this method, including calling[setContentView(View)](https://developer.android.com/reference/android/app/Dialog#setContentView(android.view.View)).

<br />

|                                                                                                                                                              Parameters                                                                                                                                                               ||
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `savedInstanceState` | `Bundle`: If this dialog is being reinitialized after a the hosting activity was previously shut down, holds the result from the most recent call to[Dialog.onSaveInstanceState()](https://developer.android.com/reference/android/app/Dialog#onSaveInstanceState()), or null if this is the first time. <br /> |