# AlertDialog

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/v7/app/AlertDialog#nestedclasses)\|[Inherited Constants](https://developer.android.com/reference/android/support/v7/app/AlertDialog#inhconstants)\|[Protected Ctors](https://developer.android.com/reference/android/support/v7/app/AlertDialog#proctors)\|[Methods](https://developer.android.com/reference/android/support/v7/app/AlertDialog#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/v7/app/AlertDialog#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/app/AlertDialog#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)  

# AlertDialog

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
AlertDialog
`  
`


``


``

extends `[AppCompatDialog](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog)`


``


implements

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


`

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

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)Known Direct Subclasses [MediaRouteControllerDialog](https://developer.android.com/reference/android/support/v7/app/MediaRouteControllerDialog) |-------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| | [MediaRouteControllerDialog](https://developer.android.com/reference/android/support/v7/app/MediaRouteControllerDialog) | This class implements the route controller dialog for[MediaRouter](https://developer.android.com/reference/android/support/v7/media/MediaRouter). | |

<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[android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_ALT_FOCUSABLE_IM)for you based on whether any views in the dialog return true from[View.onCheckIsTextEditor()](https://developer.android.com/reference/android/view/View.html#onCheckIsTextEditor()). Generally you want this set for a Dialog without text editors, so that it will be placed on top of the current input method UI. You can modify this behavior by forcing the flag to your desired mode after calling[onCreate(Bundle)](https://developer.android.com/reference/android/support/v7/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/support/v7/app/AlertDialog.Builder) <br /> |

|                                                                                                                                                                                                                                ### Inherited constants                                                                                                                                                                                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From interface` android.content.DialogInterface ` |-------|--------------------------| | `int` | `BUTTON1` <br />         | | `int` | `BUTTON2` <br />         | | `int` | `BUTTON3` <br />         | | `int` | `BUTTON_NEGATIVE` <br /> | | `int` | `BUTTON_NEUTRAL` <br />  | | `int` | `BUTTON_POSITIVE` <br /> | |

|                                                                                                                                                                                                                      ### Protected constructors                                                                                                                                                                                                                       ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog#AlertDialog(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) `                                                                                                                                                                                                                                    |
| ` `[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog#AlertDialog(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int themeResId) ` Construct an AlertDialog that uses an explicit theme.                                                                                                                                                         |
| ` `[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog#AlertDialog(android.content.Context, boolean, android.content.DialogInterface.OnCancelListener))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, boolean cancelable, `[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html)` cancelListener) ` |

|                                                                                                                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                                                                                                                             ||
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Button](https://developer.android.com/reference/android/widget/Button.html)     | ` `[getButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog#getButton(int))`(int whichButton) ` Gets one of the buttons used in the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` `[ListView](https://developer.android.com/reference/android/widget/ListView.html) | ` `[getListView](https://developer.android.com/reference/android/support/v7/app/AlertDialog#getListView())`() ` Gets the list view used in the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` boolean`                                                                          | ` `[onKeyDown](https://developer.android.com/reference/android/support/v7/app/AlertDialog#onKeyDown(int, android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` event) `                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` boolean`                                                                          | ` `[onKeyUp](https://developer.android.com/reference/android/support/v7/app/AlertDialog#onKeyUp(int, android.view.KeyEvent))`(int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` event) `                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void`                                                                             | ` `[setButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setButton(int, java.lang.CharSequence, android.graphics.drawable.Drawable, android.content.DialogInterface.OnClickListener))`(int whichButton, CharSequence text, `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Sets an icon to be displayed along with the button text and a listener to be invoked when the positive button of the dialog is pressed. |
| ` void`                                                                             | ` `[setButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setButton(int, java.lang.CharSequence, android.content.DialogInterface.OnClickListener))`(int whichButton, CharSequence text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Sets a listener to be invoked when the positive button of the dialog is pressed.                                                                                                                                                                                                |
| ` void`                                                                             | ` `[setButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setButton(int, java.lang.CharSequence, android.os.Message))`(int whichButton, CharSequence text, `[Message](https://developer.android.com/reference/android/os/Message.html)` msg) ` Sets a message to be sent when a button is pressed.                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                             | ` `[setCustomTitle](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setCustomTitle(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` customTitleView) ` This method has no effect if called after[show()](https://developer.android.com/reference/android/app/Dialog.html#show()).                                                                                                                                                                                                                                                                                             |
| ` void`                                                                             | ` `[setIcon](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon) ` Set the[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)to be used in the title.                                                                                                                                                                                                                                                                                |
| ` void`                                                                             | ` `[setIcon](https://developer.android.com/reference/android/support/v7/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/support/v7/app/AlertDialog#setIconAttribute(int))`(int attrId) ` Sets an icon as supplied by a theme attribute.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` void`                                                                             | ` `[setMessage](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setMessage(java.lang.CharSequence))`(CharSequence message) ` Sets the message to display.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void`                                                                             | ` `[setTitle](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setTitle(java.lang.CharSequence))`(CharSequence title) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`                                                                             | ` `[setView](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setView(android.view.View, int, int, int, int))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom) ` Set the view to display in the dialog, specifying the spacing to appear around that view.                                                                                                                                                                                                                                             |
| ` void`                                                                             | ` `[setView](https://developer.android.com/reference/android/support/v7/app/AlertDialog#setView(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` view) ` Set the view to display in the dialog.                                                                                                                                                                                                                                                                                                                                                                                                          |

|                                                                                                      ### Protected methods                                                                                                       ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[onCreate](https://developer.android.com/reference/android/support/v7/app/AlertDialog#onCreate(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` savedInstanceState) ` |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From class` `[android.support.v7.app.AppCompatDialog](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog)` ` |----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                                  | ` `[addContentView](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#addContentView(android.view.View, android.view.ViewGroup.LayoutParams))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html)` params) `                   | | ` <T extends `[View](https://developer.android.com/reference/android/view/View.html)`> T`                | ` `[findViewById](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#findViewById(int))`(int id) `                                                                                                                                                                                                                                                                      | | ` `[AppCompatDelegate](https://developer.android.com/reference/android/support/v7/app/AppCompatDelegate) | ` `[getDelegate](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#getDelegate())`() `                                                                                                                                                                                                                                                                                 | | ` `[ActionBar](https://developer.android.com/reference/android/support/v7/app/ActionBar)                 | ` `[getSupportActionBar](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#getSupportActionBar())`() ` Support library version of[getActionBar()](https://developer.android.com/reference/android/app/Dialog.html#getActionBar()).                                                                                                                                     | | ` void`                                                                                                  | ` `[onCreate](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#onCreate(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` savedInstanceState) `                                                                                                                                                                         | | ` void`                                                                                                  | ` `[onStop](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#onStop())`() `                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                  | ` `[onSupportActionModeFinished](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#onSupportActionModeFinished(android.support.v7.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)` mode) ` Called when a support action mode has finished.                                                                | | ` void`                                                                                                  | ` `[onSupportActionModeStarted](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#onSupportActionModeStarted(android.support.v7.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)` mode) ` Called when a support action mode has been started.                                                              | | ` `[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)              | ` `[onWindowStartingSupportActionMode](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#onWindowStartingSupportActionMode(android.support.v7.view.ActionMode.Callback))`(`[ActionMode.Callback](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback)` callback) ` Called when a support action mode is being started for this window. | | ` void`                                                                                                  | ` `[setContentView](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#setContentView(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` view) `                                                                                                                                                                             | | ` void`                                                                                                  | ` `[setContentView](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#setContentView(int))`(int layoutResID) `                                                                                                                                                                                                                                                         | | ` void`                                                                                                  | ` `[setContentView](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#setContentView(android.view.View, android.view.ViewGroup.LayoutParams))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html)` params) `                   | | ` void`                                                                                                  | ` `[setTitle](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#setTitle(java.lang.CharSequence))`(CharSequence title) `                                                                                                                                                                                                                                               | | ` void`                                                                                                  | ` `[setTitle](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#setTitle(int))`(int titleId) `                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                               | ` `[supportRequestWindowFeature](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog#supportRequestWindowFeature(int))`(int featureId) ` Enable extended support library window features.                                                                                                                                                                                | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From class` `[android.app.Dialog](https://developer.android.com/reference/android/app/Dialog.html)` ` |-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                         | ` addContentView(`[View](https://developer.android.com/reference/android/view/View.html)` arg0, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html)` arg1) `                                                                                                             | | ` void`                                                                                         | ` cancel() `                                                                                                                                                                                                                                                                                                                     | | ` void`                                                                                         | ` closeOptionsMenu() `                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                         | ` create() `                                                                                                                                                                                                                                                                                                                     | | ` void`                                                                                         | ` dismiss() `                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                      | ` dispatchGenericMotionEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                                                                                                      | | ` boolean`                                                                                      | ` dispatchKeyEvent(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg0) `                                                                                                                                                                                                                      | | ` boolean`                                                                                      | ` dispatchKeyShortcutEvent(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg0) `                                                                                                                                                                                                              | | ` boolean`                                                                                      | ` dispatchPopulateAccessibilityEvent(`[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)` arg0) `                                                                                                                                                                  | | ` boolean`                                                                                      | ` dispatchTouchEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                                                                                                              | | ` boolean`                                                                                      | ` dispatchTrackballEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                                                                                                          | | ` <T extends `[View](https://developer.android.com/reference/android/view/View.html)`> T`       | ` findViewById(int arg0) `                                                                                                                                                                                                                                                                                                       | | ` `[ActionBar](https://developer.android.com/reference/android/app/ActionBar.html)              | ` getActionBar() `                                                                                                                                                                                                                                                                                                               | | ` final `[Context](https://developer.android.com/reference/android/content/Context.html)        | ` getContext() `                                                                                                                                                                                                                                                                                                                 | | ` `[View](https://developer.android.com/reference/android/view/View.html)                       | ` getCurrentFocus() `                                                                                                                                                                                                                                                                                                            | | ` `[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html)   | ` getLayoutInflater() `                                                                                                                                                                                                                                                                                                          | | ` final `[Activity](https://developer.android.com/reference/android/app/Activity.html)          | ` getOwnerActivity() `                                                                                                                                                                                                                                                                                                           | | ` final `[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent.html)   | ` getSearchEvent() `                                                                                                                                                                                                                                                                                                             | | ` final int`                                                                                    | ` getVolumeControlStream() `                                                                                                                                                                                                                                                                                                     | | ` `[Window](https://developer.android.com/reference/android/view/Window.html)                   | ` getWindow() `                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                         | ` hide() `                                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                         | ` invalidateOptionsMenu() `                                                                                                                                                                                                                                                                                                      | | ` boolean`                                                                                      | ` isShowing() `                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                         | ` onActionModeFinished(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html)` arg0) `                                                                                                                                                                                                              | | ` void`                                                                                         | ` onActionModeStarted(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html)` arg0) `                                                                                                                                                                                                               | | ` void`                                                                                         | ` onAttachedToWindow() `                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                         | ` onBackPressed() `                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                         | ` onContentChanged() `                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                      | ` onContextItemSelected(`[MenuItem](https://developer.android.com/reference/android/view/MenuItem.html)` arg0) `                                                                                                                                                                                                                 | | ` void`                                                                                         | ` onContextMenuClosed(`[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg0) `                                                                                                                                                                                                                           | | ` void`                                                                                         | ` onCreate(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                                    | | ` void`                                                                                         | ` onCreateContextMenu(`[ContextMenu](https://developer.android.com/reference/android/view/ContextMenu.html)` arg0, `[View](https://developer.android.com/reference/android/view/View.html)` arg1, `[ContextMenu.ContextMenuInfo](https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html)` arg2) ` | | ` boolean`                                                                                      | ` onCreateOptionsMenu(`[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg0) `                                                                                                                                                                                                                           | | ` boolean`                                                                                      | ` onCreatePanelMenu(int arg0, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg1) `                                                                                                                                                                                                                   | | ` `[View](https://developer.android.com/reference/android/view/View.html)                       | ` onCreatePanelView(int arg0) `                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                         | ` onDetachedFromWindow() `                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                      | ` onGenericMotionEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                                                                                                            | | ` boolean`                                                                                      | ` onKeyDown(int arg0, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg1) `                                                                                                                                                                                                                   | | ` boolean`                                                                                      | ` onKeyLongPress(int arg0, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg1) `                                                                                                                                                                                                              | | ` boolean`                                                                                      | ` onKeyMultiple(int arg0, int arg1, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg2) `                                                                                                                                                                                                     | | ` boolean`                                                                                      | ` onKeyShortcut(int arg0, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg1) `                                                                                                                                                                                                               | | ` boolean`                                                                                      | ` onKeyUp(int arg0, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg1) `                                                                                                                                                                                                                     | | ` boolean`                                                                                      | ` onMenuItemSelected(int arg0, `[MenuItem](https://developer.android.com/reference/android/view/MenuItem.html)` arg1) `                                                                                                                                                                                                          | | ` boolean`                                                                                      | ` onMenuOpened(int arg0, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg1) `                                                                                                                                                                                                                        | | ` boolean`                                                                                      | ` onOptionsItemSelected(`[MenuItem](https://developer.android.com/reference/android/view/MenuItem.html)` arg0) `                                                                                                                                                                                                                 | | ` void`                                                                                         | ` onOptionsMenuClosed(`[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg0) `                                                                                                                                                                                                                           | | ` void`                                                                                         | ` onPanelClosed(int arg0, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg1) `                                                                                                                                                                                                                       | | ` boolean`                                                                                      | ` onPrepareOptionsMenu(`[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg0) `                                                                                                                                                                                                                          | | ` boolean`                                                                                      | ` onPreparePanel(int arg0, `[View](https://developer.android.com/reference/android/view/View.html)` arg1, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg2) `                                                                                                                                       | | ` void`                                                                                         | ` onRestoreInstanceState(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` arg0) `                                                                                                                                                                                                                      | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                     | ` onSaveInstanceState() `                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                      | ` onSearchRequested(`[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent.html)` arg0) `                                                                                                                                                                                                               | | ` boolean`                                                                                      | ` onSearchRequested() `                                                                                                                                                                                                                                                                                                          | | ` void`                                                                                         | ` onStart() `                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                         | ` onStop() `                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                      | ` onTouchEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                                                                                                                    | | ` boolean`                                                                                      | ` onTrackballEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                                                                                                                | | ` void`                                                                                         | ` onWindowAttributesChanged(`[WindowManager.LayoutParams](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html)` arg0) `                                                                                                                                                                         | | ` void`                                                                                         | ` onWindowFocusChanged(boolean arg0) `                                                                                                                                                                                                                                                                                           | | ` `[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html)           | ` onWindowStartingActionMode(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback.html)` arg0) `                                                                                                                                                                                      | | ` `[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html)           | ` onWindowStartingActionMode(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback.html)` arg0, int arg1) `                                                                                                                                                                            | | ` void`                                                                                         | ` openContextMenu(`[View](https://developer.android.com/reference/android/view/View.html)` arg0) `                                                                                                                                                                                                                               | | ` void`                                                                                         | ` openOptionsMenu() `                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                         | ` registerForContextMenu(`[View](https://developer.android.com/reference/android/view/View.html)` arg0) `                                                                                                                                                                                                                        | | ` final boolean`                                                                                | ` requestWindowFeature(int arg0) `                                                                                                                                                                                                                                                                                               | | ` final <T extends `[View](https://developer.android.com/reference/android/view/View.html)`> T` | ` requireViewById(int arg0) `                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                         | ` setCancelMessage(`[Message](https://developer.android.com/reference/android/os/Message.html)` arg0) `                                                                                                                                                                                                                          | | ` void`                                                                                         | ` setCancelable(boolean arg0) `                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                         | ` setCanceledOnTouchOutside(boolean arg0) `                                                                                                                                                                                                                                                                                      | | ` void`                                                                                         | ` setContentView(int arg0) `                                                                                                                                                                                                                                                                                                     | | ` void`                                                                                         | ` setContentView(`[View](https://developer.android.com/reference/android/view/View.html)` arg0, `[ViewGroup.LayoutParams](https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html)` arg1) `                                                                                                             | | ` void`                                                                                         | ` setContentView(`[View](https://developer.android.com/reference/android/view/View.html)` arg0) `                                                                                                                                                                                                                                | | ` void`                                                                                         | ` setDismissMessage(`[Message](https://developer.android.com/reference/android/os/Message.html)` arg0) `                                                                                                                                                                                                                         | | ` final void`                                                                                   | ` setFeatureDrawable(int arg0, `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` arg1) `                                                                                                                                                                                             | | ` final void`                                                                                   | ` setFeatureDrawableAlpha(int arg0, int arg1) `                                                                                                                                                                                                                                                                                  | | ` final void`                                                                                   | ` setFeatureDrawableResource(int arg0, int arg1) `                                                                                                                                                                                                                                                                               | | ` final void`                                                                                   | ` setFeatureDrawableUri(int arg0, `[Uri](https://developer.android.com/reference/android/net/Uri.html)` arg1) `                                                                                                                                                                                                                  | | ` void`                                                                                         | ` setOnCancelListener(`[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html)` arg0) `                                                                                                                                                                | | ` void`                                                                                         | ` setOnDismissListener(`[DialogInterface.OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html)` arg0) `                                                                                                                                                             | | ` void`                                                                                         | ` setOnKeyListener(`[DialogInterface.OnKeyListener](https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener.html)` arg0) `                                                                                                                                                                         | | ` void`                                                                                         | ` setOnShowListener(`[DialogInterface.OnShowListener](https://developer.android.com/reference/android/content/DialogInterface.OnShowListener.html)` arg0) `                                                                                                                                                                      | | ` final void`                                                                                   | ` setOwnerActivity(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` arg0) `                                                                                                                                                                                                                       | | ` void`                                                                                         | ` setTitle(CharSequence arg0) `                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                         | ` setTitle(int arg0) `                                                                                                                                                                                                                                                                                                           | | ` final void`                                                                                   | ` setVolumeControlStream(int arg0) `                                                                                                                                                                                                                                                                                             | | ` void`                                                                                         | ` show() `                                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                         | ` takeKeyEvents(boolean arg0) `                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                         | ` unregisterForContextMenu(`[View](https://developer.android.com/reference/android/view/View.html)` arg0) `                                                                                                                                                                                                                      | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From interface` `[android.support.v7.app.AppCompatCallback](https://developer.android.com/reference/android/support/v7/app/AppCompatCallback)` ` |------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void`                                                                                     | ` `[onSupportActionModeFinished](https://developer.android.com/reference/android/support/v7/app/AppCompatCallback#onSupportActionModeFinished(android.support.v7.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)` mode) ` Called when a support action mode has finished.                                                                | | ` abstract void`                                                                                     | ` `[onSupportActionModeStarted](https://developer.android.com/reference/android/support/v7/app/AppCompatCallback#onSupportActionModeStarted(android.support.v7.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)` mode) ` Called when a support action mode has been started.                                                              | | ` abstract `[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode) | ` `[onWindowStartingSupportActionMode](https://developer.android.com/reference/android/support/v7/app/AppCompatCallback#onWindowStartingSupportActionMode(android.support.v7.view.ActionMode.Callback))`(`[ActionMode.Callback](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback)` callback) ` Called when a support action mode is being started for this window. | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From interface` `[android.content.DialogInterface](https://developer.android.com/reference/android/content/DialogInterface.html)` ` |------------------|---------------| | ` abstract void` | ` cancel() `  | | ` abstract void` | ` dismiss() ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From interface` `[android.view.Window.Callback](https://developer.android.com/reference/android/view/Window.Callback.html)` ` |------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                                            | ` dispatchGenericMotionEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                    | | ` abstract boolean`                                                                            | ` dispatchKeyEvent(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg0) `                                                                                                                                    | | ` abstract boolean`                                                                            | ` dispatchKeyShortcutEvent(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg0) `                                                                                                                            | | ` abstract boolean`                                                                            | ` dispatchPopulateAccessibilityEvent(`[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)` arg0) `                                                                                | | ` abstract boolean`                                                                            | ` dispatchTouchEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                            | | ` abstract boolean`                                                                            | ` dispatchTrackballEvent(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                        | | ` abstract void`                                                                               | ` onActionModeFinished(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html)` arg0) `                                                                                                                            | | ` abstract void`                                                                               | ` onActionModeStarted(`[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html)` arg0) `                                                                                                                             | | ` abstract void`                                                                               | ` onAttachedToWindow() `                                                                                                                                                                                                                       | | ` abstract void`                                                                               | ` onContentChanged() `                                                                                                                                                                                                                         | | ` abstract boolean`                                                                            | ` onCreatePanelMenu(int arg0, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg1) `                                                                                                                                 | | ` abstract `[View](https://developer.android.com/reference/android/view/View.html)             | ` onCreatePanelView(int arg0) `                                                                                                                                                                                                                | | ` abstract void`                                                                               | ` onDetachedFromWindow() `                                                                                                                                                                                                                     | | ` abstract boolean`                                                                            | ` onMenuItemSelected(int arg0, `[MenuItem](https://developer.android.com/reference/android/view/MenuItem.html)` arg1) `                                                                                                                        | | ` abstract boolean`                                                                            | ` onMenuOpened(int arg0, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg1) `                                                                                                                                      | | ` abstract void`                                                                               | ` onPanelClosed(int arg0, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg1) `                                                                                                                                     | | ` default void`                                                                                | ` onPointerCaptureChanged(boolean arg0) `                                                                                                                                                                                                      | | ` abstract boolean`                                                                            | ` onPreparePanel(int arg0, `[View](https://developer.android.com/reference/android/view/View.html)` arg1, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg2) `                                                     | | ` default void`                                                                                | ` onProvideKeyboardShortcuts(List<`[KeyboardShortcutGroup](https://developer.android.com/reference/android/view/KeyboardShortcutGroup.html)`> arg0, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` arg1, int arg2) ` | | ` abstract boolean`                                                                            | ` onSearchRequested() `                                                                                                                                                                                                                        | | ` abstract boolean`                                                                            | ` onSearchRequested(`[SearchEvent](https://developer.android.com/reference/android/view/SearchEvent.html)` arg0) `                                                                                                                             | | ` abstract void`                                                                               | ` onWindowAttributesChanged(`[WindowManager.LayoutParams](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html)` arg0) `                                                                                       | | ` abstract void`                                                                               | ` onWindowFocusChanged(boolean arg0) `                                                                                                                                                                                                         | | ` abstract `[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html) | ` onWindowStartingActionMode(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback.html)` arg0) `                                                                                                    | | ` abstract `[ActionMode](https://developer.android.com/reference/android/view/ActionMode.html) | ` onWindowStartingActionMode(`[ActionMode.Callback](https://developer.android.com/reference/android/view/ActionMode.Callback.html)` arg0, int arg1) `                                                                                          | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From interface` `[android.view.KeyEvent.Callback](https://developer.android.com/reference/android/view/KeyEvent.Callback.html)` ` |---------------------|------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean` | ` onKeyDown(int arg0, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg1) `               | | ` abstract boolean` | ` onKeyLongPress(int arg0, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg1) `          | | ` abstract boolean` | ` onKeyMultiple(int arg0, int arg1, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg2) ` | | ` abstract boolean` | ` onKeyUp(int arg0, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` arg1) `                 | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog#)From interface` `[android.view.View.OnCreateContextMenuListener](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener.html)` ` |------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` onCreateContextMenu(`[ContextMenu](https://developer.android.com/reference/android/view/ContextMenu.html)` arg0, `[View](https://developer.android.com/reference/android/view/View.html)` arg1, `[ContextMenu.ContextMenuInfo](https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html)` arg2) ` | ||

## Protected constructors

### AlertDialog

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
AlertDialog (Context context)
```

<br />

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |

### AlertDialog

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

|           Parameters           ||
|--------------|------------------|
| `context`    | `Context` <br /> |
| `themeResId` | `int` <br />     |

### AlertDialog

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

<br />

<br />

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

## Public methods

### getButton

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

<br />

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

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

### getListView

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ListView getListView ()
```

Gets the list view used in the dialog.

<br />

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

### onKeyDown

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

<br />

<br />

|          Parameters          ||
|-----------|-------------------|
| `keyCode` | `int` <br />      |
| `event`   | `KeyEvent` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### onKeyUp

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

<br />

<br />

|          Parameters          ||
|-----------|-------------------|
| `keyCode` | `int` <br />      |
| `event`   | `KeyEvent` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### setButton

added in[version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

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

### setButton

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

|                                                                                                                                                                                                           Parameters                                                                                                                                                                                                            ||
|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `whichButton` | `int`: Which button to set the listener on, can be one of[BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE),[BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEGATIVE), or[BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface.html#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.html)to use. <br />                                                                                                                                                                                                                              |

### setButton

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

|                                                                                                                                                                                                           Parameters                                                                                                                                                                                                            ||
|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `whichButton` | `int`: Which button to set the message for, can be one of[BUTTON_POSITIVE](https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE),[BUTTON_NEGATIVE](https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_NEGATIVE), or[BUTTON_NEUTRAL](https://developer.android.com/reference/android/content/DialogInterface.html#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.html)to be sent when clicked. <br />                                                                                                                                                                                                                                                                                          |

### setCustomTitle

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

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

**See also:**

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

### setIcon

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Set the[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)to be used in the title.

<br />

|                                        Parameters                                         ||
|--------|-----------------------------------------------------------------------------------|
| `icon` | `Drawable`: Drawable to use as the icon or null if you don't want an icon. <br /> |

### setIcon

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Sets 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 /> |

### setMessage

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Sets the message to display.

<br />

|                               Parameters                                ||
|-----------|--------------------------------------------------------------|
| `message` | `CharSequence`: The message to display in the dialog. <br /> |

### setTitle

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

<br />

<br />

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

### setView

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<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[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

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

## Protected methods

### onCreate

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

<br />

<br />

|              Parameters               ||
|----------------------|-----------------|
| `savedInstanceState` | `Bundle` <br /> |

-

  ## Interfaces

  - [ActionBar.OnMenuVisibilityListener](https://developer.android.com/reference/android/support/v7/app/ActionBar.OnMenuVisibilityListener)
  - [ActionBar.OnNavigationListener](https://developer.android.com/reference/android/support/v7/app/ActionBar.OnNavigationListener)
  - [ActionBar.TabListener](https://developer.android.com/reference/android/support/v7/app/ActionBar.TabListener)
  - [ActionBarDrawerToggle.Delegate](https://developer.android.com/reference/android/support/v7/app/ActionBarDrawerToggle.Delegate)
  - [ActionBarDrawerToggle.DelegateProvider](https://developer.android.com/reference/android/support/v7/app/ActionBarDrawerToggle.DelegateProvider)
  - [AppCompatCallback](https://developer.android.com/reference/android/support/v7/app/AppCompatCallback)
-

  ## Classes

  - [ActionBar](https://developer.android.com/reference/android/support/v7/app/ActionBar)
  - [ActionBar.LayoutParams](https://developer.android.com/reference/android/support/v7/app/ActionBar.LayoutParams)
  - [ActionBar.Tab](https://developer.android.com/reference/android/support/v7/app/ActionBar.Tab)
  - [ActionBarDrawerToggle](https://developer.android.com/reference/android/support/v7/app/ActionBarDrawerToggle)
  - [AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog)
  - [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder)
  - [AppCompatActivity](https://developer.android.com/reference/android/support/v7/app/AppCompatActivity)
  - [AppCompatDelegate](https://developer.android.com/reference/android/support/v7/app/AppCompatDelegate)
  - [AppCompatDialog](https://developer.android.com/reference/android/support/v7/app/AppCompatDialog)
  - [AppCompatDialogFragment](https://developer.android.com/reference/android/support/v7/app/AppCompatDialogFragment)
  - [AppCompatViewInflater](https://developer.android.com/reference/android/support/v7/app/AppCompatViewInflater)
  - [MediaRouteActionProvider](https://developer.android.com/reference/android/support/v7/app/MediaRouteActionProvider)
  - [MediaRouteButton](https://developer.android.com/reference/android/support/v7/app/MediaRouteButton)
  - [MediaRouteChooserDialog](https://developer.android.com/reference/android/support/v7/app/MediaRouteChooserDialog)
  - [MediaRouteChooserDialogFragment](https://developer.android.com/reference/android/support/v7/app/MediaRouteChooserDialogFragment)
  - [MediaRouteControllerDialog](https://developer.android.com/reference/android/support/v7/app/MediaRouteControllerDialog)
  - [MediaRouteControllerDialogFragment](https://developer.android.com/reference/android/support/v7/app/MediaRouteControllerDialogFragment)
  - [MediaRouteDialogFactory](https://developer.android.com/reference/android/support/v7/app/MediaRouteDialogFactory)
  - [MediaRouteDiscoveryFragment](https://developer.android.com/reference/android/support/v7/app/MediaRouteDiscoveryFragment)