# AlertDialog.Builder

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:[Ctors](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#)  

# AlertDialog.Builder

| 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
static


class
AlertDialog.Builder
`  
`

extends Object


``


`

|---|--------------------------------------------|
| java.lang.Object                              ||
| ↳ | android.support.v7.app.AlertDialog.Builder |

<br />

*** ** * ** ***

## Summary

|                                                                                                                                                                   ### Public constructors                                                                                                                                                                   ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#AlertDialog.Builder(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Creates a builder for an alert dialog that uses the default alert dialog theme.                  |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#AlertDialog.Builder(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int themeResId) ` Creates a builder for an alert dialog that uses an explicit theme resource. |

|                                                                                                                                                                                                                                                                                                                                                                                                            ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                             ||
|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog)                 | ` `[create](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#create())`() ` Creates an[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog)with the arguments supplied to this builder.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` `[Context](https://developer.android.com/reference/android/content/Context.html)                           | ` `[getContext](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#getContext())`() ` Returns a[Context](https://developer.android.com/reference/android/content/Context.html)with the appropriate theme for dialogs created by this Builder.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setAdapter](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setAdapter(android.widget.ListAdapter, android.content.DialogInterface.OnClickListener))`(`[ListAdapter](https://developer.android.com/reference/android/widget/ListAdapter.html)` adapter, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a list of items, which are supplied by the given[ListAdapter](https://developer.android.com/reference/android/widget/ListAdapter.html), to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                 |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setCancelable](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setCancelable(boolean))`(boolean cancelable) ` Sets whether the dialog is cancelable or not.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setCursor](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setCursor(android.database.Cursor, android.content.DialogInterface.OnClickListener, java.lang.String))`(`[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener, String labelColumn) ` Set a list of items, which are supplied by the given[Cursor](https://developer.android.com/reference/android/database/Cursor.html), to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setCustomTitle](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setCustomTitle(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` customTitleView) ` Set the title using the custom view`customTitleView`.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setIcon](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#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.                                                                                                                                                                                                                                                                                                                                              |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setIcon](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setIcon(int))`(int iconId) ` Set the resource id of the[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)to be used in the title.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setIconAttribute](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setIconAttribute(int))`(int attrId) ` Set an icon as supplied by a theme attribute.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setInverseBackgroundForced](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setInverseBackgroundForced(boolean))`(boolean useInverseBackground) ` *This method was deprecated in API level 24.1.0. This flag is only used for pre-Material themes. Instead, specify the window background using on the alert dialog theme.*                                                                                                                                                                                                                                                                                                                                                          |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setItems(int, android.content.DialogInterface.OnClickListener))`(int itemsId, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                                                                                                                                                                                                         |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setItems(java.lang.CharSequence[], android.content.DialogInterface.OnClickListener))`(CharSequence[] items, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                                                                                                                                                                           |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setMessage](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setMessage(int))`(int messageId) ` Set the message to display using the given resource id.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setMessage](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setMessage(java.lang.CharSequence))`(CharSequence message) ` Set the message to display.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setMultiChoiceItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setMultiChoiceItems(java.lang.CharSequence[], boolean[], android.content.DialogInterface.OnMultiChoiceClickListener))`(CharSequence[] items, boolean[] checkedItems, `[DialogInterface.OnMultiChoiceClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                                                                                 |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setMultiChoiceItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setMultiChoiceItems(android.database.Cursor, java.lang.String, java.lang.String, android.content.DialogInterface.OnMultiChoiceClickListener))`(`[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor, String isCheckedColumn, String labelColumn, `[DialogInterface.OnMultiChoiceClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                  |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setMultiChoiceItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setMultiChoiceItems(int, boolean[], android.content.DialogInterface.OnMultiChoiceClickListener))`(int itemsId, boolean[] checkedItems, `[DialogInterface.OnMultiChoiceClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                                                                                                               |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setNegativeButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setNegativeButton(java.lang.CharSequence, android.content.DialogInterface.OnClickListener))`(CharSequence text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a listener to be invoked when the negative button of the dialog is pressed.                                                                                                                                                                                                                                                                     |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setNegativeButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setNegativeButton(int, android.content.DialogInterface.OnClickListener))`(int textId, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a listener to be invoked when the negative button of the dialog is pressed.                                                                                                                                                                                                                                                                                               |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setNegativeButtonIcon](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setNegativeButtonIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon) ` Set an icon to be displayed for the negative button.                                                                                                                                                                                                                                                                                                                                                                                        |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setNeutralButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setNeutralButton(java.lang.CharSequence, android.content.DialogInterface.OnClickListener))`(CharSequence text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a listener to be invoked when the neutral button of the dialog is pressed.                                                                                                                                                                                                                                                                        |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setNeutralButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setNeutralButton(int, android.content.DialogInterface.OnClickListener))`(int textId, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a listener to be invoked when the neutral button of the dialog is pressed.                                                                                                                                                                                                                                                                                                  |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setNeutralButtonIcon](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setNeutralButtonIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon) ` Set an icon to be displayed for the neutral button.                                                                                                                                                                                                                                                                                                                                                                                           |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setOnCancelListener](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setOnCancelListener(android.content.DialogInterface.OnCancelListener))`(`[DialogInterface.OnCancelListener](https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html)` onCancelListener) ` Sets the callback that will be called if the dialog is canceled.                                                                                                                                                                                                                                                                                                                |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setOnDismissListener](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setOnDismissListener(android.content.DialogInterface.OnDismissListener))`(`[DialogInterface.OnDismissListener](https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html)` onDismissListener) ` Sets the callback that will be called when the dialog is dismissed for any reason.                                                                                                                                                                                                                                                                                        |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setOnItemSelectedListener](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener))`(`[AdapterView.OnItemSelectedListener](https://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html)` listener) ` Sets a listener to be invoked when an item in the list is selected.                                                                                                                                                                                                                                                                                                     |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setOnKeyListener](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setOnKeyListener(android.content.DialogInterface.OnKeyListener))`(`[DialogInterface.OnKeyListener](https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener.html)` onKeyListener) ` Sets the callback that will be called if a key is dispatched to the dialog.                                                                                                                                                                                                                                                                                                                       |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setPositiveButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setPositiveButton(int, android.content.DialogInterface.OnClickListener))`(int textId, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a listener to be invoked when the positive button of the dialog is pressed.                                                                                                                                                                                                                                                                                               |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setPositiveButton](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setPositiveButton(java.lang.CharSequence, android.content.DialogInterface.OnClickListener))`(CharSequence text, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a listener to be invoked when the positive button of the dialog is pressed.                                                                                                                                                                                                                                                                     |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setPositiveButtonIcon](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setPositiveButtonIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon) ` Set an icon to be displayed for the positive button.                                                                                                                                                                                                                                                                                                                                                                                        |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setSingleChoiceItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setSingleChoiceItems(int, int, android.content.DialogInterface.OnClickListener))`(int itemsId, int checkedItem, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                                                                                                                                                           |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setSingleChoiceItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setSingleChoiceItems(android.widget.ListAdapter, int, android.content.DialogInterface.OnClickListener))`(`[ListAdapter](https://developer.android.com/reference/android/widget/ListAdapter.html)` adapter, int checkedItem, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                                               |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setSingleChoiceItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setSingleChoiceItems(android.database.Cursor, int, java.lang.String, android.content.DialogInterface.OnClickListener))`(`[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor, int checkedItem, String labelColumn, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                     |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setSingleChoiceItems](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setSingleChoiceItems(java.lang.CharSequence[], int, android.content.DialogInterface.OnClickListener))`(CharSequence[] items, int checkedItem, `[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)` listener) ` Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.                                                                                                                                                                             |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setTitle](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setTitle(java.lang.CharSequence))`(CharSequence title) ` Set the title displayed in the[Dialog](https://developer.android.com/reference/android/app/Dialog.html).                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setTitle](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setTitle(int))`(int titleId) ` Set the title using the given resource id.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setView](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setView(int))`(int layoutResId) ` Set a custom view resource to be the contents of the Dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` `[AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | ` `[setView](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setView(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` view) ` Sets a custom view to be the contents of the alert dialog.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` `[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog)                 | ` `[show](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#show())`() ` Creates an[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog)with the arguments supplied to this builder and immediately displays the dialog.                                                                                                                                                                                                                                                                                                                                                                                                                               |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#)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() `                    | ||

## Public constructors

### AlertDialog.Builder

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

```
AlertDialog.Builder (Context context)
```

Creates a builder for an alert dialog that uses the default alert dialog theme.

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

<br />

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

### AlertDialog.Builder

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

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

Creates a builder for an alert dialog that uses an explicit theme resource.

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

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

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

<br />

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

## Public methods

### create

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

```
AlertDialog create ()
```

Creates an[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog)with the arguments supplied to this builder.

Calling this method does not display the dialog. If no additional processing is needed,[show()](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#show())may be called instead to both create and display the dialog.

<br />

|                                              Returns                                              ||
|-------------------------------------------------------------------------------------------|--------|
| [AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog) | <br /> |

### getContext

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

```
Context getContext ()
```

Returns a[Context](https://developer.android.com/reference/android/content/Context.html)with the appropriate theme for dialogs created by this Builder. Applications should use this Context for obtaining LayoutInflaters for inflating views that will be used in the resulting dialogs, as it will cause views to be inflated with the correct theme.

<br />

|                                                       Returns                                                        ||
|---------------------------------------------------------------------------------|-------------------------------------|
| [Context](https://developer.android.com/reference/android/content/Context.html) | A Context for built Dialogs. <br /> |

### setAdapter

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

```
AlertDialog.Builder setAdapter (ListAdapter adapter, 
                DialogInterface.OnClickListener listener)
```

Set a list of items, which are supplied by the given[ListAdapter](https://developer.android.com/reference/android/widget/ListAdapter.html), to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.

<br />

|                                                                       Parameters                                                                       ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `adapter`  | `ListAdapter`: The[ListAdapter](https://developer.android.com/reference/android/widget/ListAdapter.html)to supply the list of items <br /> |
| `listener` | `DialogInterface.OnClickListener`: The listener that will be called when an item is clicked. <br />                                        |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setCancelable

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

```
AlertDialog.Builder setCancelable (boolean cancelable)
```

Sets whether the dialog is cancelable or not. Default is true.

<br />

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

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setCursor

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

```
AlertDialog.Builder setCursor (Cursor cursor, 
                DialogInterface.OnClickListener listener, 
                String labelColumn)
```

Set a list of items, which are supplied by the given[Cursor](https://developer.android.com/reference/android/database/Cursor.html), to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.

<br />

|                                                                  Parameters                                                                  ||
|---------------|-------------------------------------------------------------------------------------------------------------------------------|
| `cursor`      | `Cursor`: The[Cursor](https://developer.android.com/reference/android/database/Cursor.html)to supply the list of items <br /> |
| `listener`    | `DialogInterface.OnClickListener`: The listener that will be called when an item is clicked. <br />                           |
| `labelColumn` | `String`: The column name on the cursor containing the string to display in the label. <br />                                 |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setCustomTitle

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

```
AlertDialog.Builder setCustomTitle (View customTitleView)
```

Set the title using the custom view`customTitleView`.

The methods[setTitle(int)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setTitle(int))and[setIcon(int)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setIcon(int))should be sufficient for most titles, but this is provided if the title needs more customization. Using this will replace the title and icon set via the other methods.

**Note:** To ensure consistent styling, the custom view should be inflated or constructed using the alert dialog's themed context obtained via[getContext()](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#getContext()).

<br />

|                              Parameters                               ||
|-------------------|----------------------------------------------------|
| `customTitleView` | `View`: the custom view to use as the title <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### setIcon

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

```
AlertDialog.Builder setIcon (Drawable icon)
```

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

**Note:** To ensure consistent styling, the drawable should be inflated or constructed using the alert dialog's themed context obtained via[getContext()](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#getContext()).

<br />

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

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### setIcon

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

```
AlertDialog.Builder setIcon (int iconId)
```

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

Takes precedence over values set using[setIcon(Drawable)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setIcon(android.graphics.drawable.Drawable)).

<br />

|       Parameters       ||
|----------|--------------|
| `iconId` | `int` <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setIconAttribute

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

```
AlertDialog.Builder setIconAttribute (int attrId)
```

Set an icon as supplied by a theme attribute. e.g.[alertDialogIcon](https://developer.android.com/reference/android/R.attr#alertDialogIcon).

Takes precedence over values set using[setIcon(int)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setIcon(int))or[setIcon(Drawable)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setIcon(android.graphics.drawable.Drawable)).

<br />

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

|                                                      Returns                                                      ||
|-----------------------------------------------------------------------------------------------------------|--------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | <br /> |

### setInverseBackgroundForced

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

```
AlertDialog.Builder setInverseBackgroundForced (boolean useInverseBackground)
```

<br />

**This method was deprecated in API level 24.1.0.**   
This flag is only used for pre-Material themes. Instead, specify the window background using on the alert dialog theme.

Sets the Dialog to use the inverse background, regardless of what the contents is.

<br />

|                                   Parameters                                    ||
|------------------------|---------------------------------------------------------|
| `useInverseBackground` | `boolean`: Whether to use the inverse background <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setItems

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

```
AlertDialog.Builder setItems (int itemsId, 
                DialogInterface.OnClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. This should be an array type i.e. R.array.foo

<br />

|                      Parameters                      ||
|------------|------------------------------------------|
| `itemsId`  | `int` <br />                             |
| `listener` | `DialogInterface.OnClickListener` <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setItems

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

```
AlertDialog.Builder setItems (CharSequence[] items, 
                DialogInterface.OnClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.

<br />

|                      Parameters                      ||
|------------|------------------------------------------|
| `items`    | `CharSequence` <br />                    |
| `listener` | `DialogInterface.OnClickListener` <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMessage

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

```
AlertDialog.Builder setMessage (int messageId)
```

Set the message to display using the given resource id.

<br />

|        Parameters         ||
|-------------|--------------|
| `messageId` | `int` <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMessage

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

```
AlertDialog.Builder setMessage (CharSequence message)
```

Set the message to display.

<br />

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

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMultiChoiceItems

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

```
AlertDialog.Builder setMultiChoiceItems (CharSequence[] items, 
                boolean[] checkedItems, 
                DialogInterface.OnMultiChoiceClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. The list will have a check mark displayed to the right of the text for each checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog.

<br />

|                                                                                                                                              Parameters                                                                                                                                              ||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `items`        | `CharSequence`: the text of the items to be displayed in the list. <br />                                                                                                                                                                                                            |
| `checkedItems` | `boolean`: specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items. <br />                                                                                                     |
| `listener`     | `DialogInterface.OnMultiChoiceClickListener`: notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMultiChoiceItems

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

```
AlertDialog.Builder setMultiChoiceItems (Cursor cursor, 
                String isCheckedColumn, 
                String labelColumn, 
                DialogInterface.OnMultiChoiceClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. The list will have a check mark displayed to the right of the text for each checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog.

<br />

|                                                                                                                                               Parameters                                                                                                                                                ||
|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `cursor`          | `Cursor`: the cursor used to provide the items. <br />                                                                                                                                                                                                                               |
| `isCheckedColumn` | `String`: specifies the column name on the cursor to use to determine whether a checkbox is checked or not. It must return an integer value where 1 means checked and 0 means unchecked. <br />                                                                                      |
| `labelColumn`     | `String`: The column name on the cursor containing the string to display in the label. <br />                                                                                                                                                                                        |
| `listener`        | `DialogInterface.OnMultiChoiceClickListener`: notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMultiChoiceItems

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

```
AlertDialog.Builder setMultiChoiceItems (int itemsId, 
                boolean[] checkedItems, 
                DialogInterface.OnMultiChoiceClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. This should be an array type, e.g. R.array.foo. The list will have a check mark displayed to the right of the text for each checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog.

<br />

|                                                                                                                                              Parameters                                                                                                                                              ||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `itemsId`      | `int`: the resource id of an array i.e. R.array.foo <br />                                                                                                                                                                                                                           |
| `checkedItems` | `boolean`: specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items. <br />                                                                                                     |
| `listener`     | `DialogInterface.OnMultiChoiceClickListener`: notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setNegativeButton

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

```
AlertDialog.Builder setNegativeButton (CharSequence text, 
                DialogInterface.OnClickListener listener)
```

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

<br />

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

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setNegativeButton

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

```
AlertDialog.Builder setNegativeButton (int textId, 
                DialogInterface.OnClickListener listener)
```

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

<br />

|                                                                                           Parameters                                                                                            ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `textId`   | `int`: The resource id of the text to display in the negative button <br />                                                                                                         |
| `listener` | `DialogInterface.OnClickListener`: The[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)to use. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setNegativeButtonIcon

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

```
AlertDialog.Builder setNegativeButtonIcon (Drawable icon)
```

Set an icon to be displayed for the negative button.

<br />

|                     Parameters                      ||
|--------|---------------------------------------------|
| `icon` | `Drawable`: The icon to be displayed <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setNeutralButton

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

```
AlertDialog.Builder setNeutralButton (CharSequence text, 
                DialogInterface.OnClickListener listener)
```

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

<br />

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

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setNeutralButton

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

```
AlertDialog.Builder setNeutralButton (int textId, 
                DialogInterface.OnClickListener listener)
```

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

<br />

|                                                                                           Parameters                                                                                            ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `textId`   | `int`: The resource id of the text to display in the neutral button <br />                                                                                                          |
| `listener` | `DialogInterface.OnClickListener`: The[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)to use. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setNeutralButtonIcon

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

```
AlertDialog.Builder setNeutralButtonIcon (Drawable icon)
```

Set an icon to be displayed for the neutral button.

<br />

|                     Parameters                      ||
|--------|---------------------------------------------|
| `icon` | `Drawable`: The icon to be displayed <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setOnCancelListener

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

```
AlertDialog.Builder setOnCancelListener (DialogInterface.OnCancelListener onCancelListener)
```

Sets the callback that will be called if the dialog is canceled.

Even in a cancelable dialog, the dialog may be dismissed for reasons other than being canceled or one of the supplied choices being selected. If you are interested in listening for all cases where the dialog is dismissed and not just when it is canceled, see[setOnDismissListener](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setOnDismissListener(android.content.DialogInterface.OnDismissListener)).

<br />

<br />

|                          Parameters                           ||
|--------------------|-------------------------------------------|
| `onCancelListener` | `DialogInterface.OnCancelListener` <br /> |

|                                                                                                                       Returns                                                                                                                        ||
|-----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methodsThis Builder object to allow for chaining of calls to set methods <br /> |

**See also:**

- [setCancelable(boolean)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setCancelable(boolean))
- [setOnDismissListener(android.content.DialogInterface.OnDismissListener)](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#setOnDismissListener(android.content.DialogInterface.OnDismissListener))  

### setOnDismissListener

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

```
AlertDialog.Builder setOnDismissListener (DialogInterface.OnDismissListener onDismissListener)
```

Sets the callback that will be called when the dialog is dismissed for any reason.

<br />

|                           Parameters                            ||
|---------------------|--------------------------------------------|
| `onDismissListener` | `DialogInterface.OnDismissListener` <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setOnItemSelectedListener

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

```
AlertDialog.Builder setOnItemSelectedListener (AdapterView.OnItemSelectedListener listener)
```

Sets a listener to be invoked when an item in the list is selected.

<br />

|                                     Parameters                                      ||
|------------|-------------------------------------------------------------------------|
| `listener` | `AdapterView.OnItemSelectedListener`: the listener to be invoked <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

**See also:**

- [setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)](https://developer.android.com/https://developer.android.com/reference/android/widget/AdapterView#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener))  

### setOnKeyListener

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

```
AlertDialog.Builder setOnKeyListener (DialogInterface.OnKeyListener onKeyListener)
```

Sets the callback that will be called if a key is dispatched to the dialog.

<br />

|                       Parameters                        ||
|-----------------|----------------------------------------|
| `onKeyListener` | `DialogInterface.OnKeyListener` <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setPositiveButton

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

```
AlertDialog.Builder setPositiveButton (int textId, 
                DialogInterface.OnClickListener listener)
```

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

<br />

|                                                                                           Parameters                                                                                            ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `textId`   | `int`: The resource id of the text to display in the positive button <br />                                                                                                         |
| `listener` | `DialogInterface.OnClickListener`: The[DialogInterface.OnClickListener](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html)to use. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setPositiveButton

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

```
AlertDialog.Builder setPositiveButton (CharSequence text, 
                DialogInterface.OnClickListener listener)
```

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

<br />

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

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setPositiveButtonIcon

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

```
AlertDialog.Builder setPositiveButtonIcon (Drawable icon)
```

Set an icon to be displayed for the positive button.

<br />

|                     Parameters                      ||
|--------|---------------------------------------------|
| `icon` | `Drawable`: The icon to be displayed <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setSingleChoiceItems

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

```
AlertDialog.Builder setSingleChoiceItems (int itemsId, 
                int checkedItem, 
                DialogInterface.OnClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. This should be an array type i.e. R.array.foo The list will have a check mark displayed to the right of the text for the checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog.

<br />

|                                                                                                                                        Parameters                                                                                                                                        ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `itemsId`     | `int`: the resource id of an array i.e. R.array.foo <br />                                                                                                                                                                                                                |
| `checkedItem` | `int`: specifies which item is checked. If -1 no items are checked. <br />                                                                                                                                                                                                |
| `listener`    | `DialogInterface.OnClickListener`: notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setSingleChoiceItems

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

```
AlertDialog.Builder setSingleChoiceItems (ListAdapter adapter, 
                int checkedItem, 
                DialogInterface.OnClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. The list will have a check mark displayed to the right of the text for the checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog.

<br />

|                                                                                                                                        Parameters                                                                                                                                        ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `adapter`     | `ListAdapter`: The[ListAdapter](https://developer.android.com/reference/android/widget/ListAdapter.html)to supply the list of items <br />                                                                                                                                |
| `checkedItem` | `int`: specifies which item is checked. If -1 no items are checked. <br />                                                                                                                                                                                                |
| `listener`    | `DialogInterface.OnClickListener`: notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setSingleChoiceItems

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

```
AlertDialog.Builder setSingleChoiceItems (Cursor cursor, 
                int checkedItem, 
                String labelColumn, 
                DialogInterface.OnClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. The list will have a check mark displayed to the right of the text for the checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog.

<br />

|                                                                                                                                        Parameters                                                                                                                                        ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `cursor`      | `Cursor`: the cursor to retrieve the items from. <br />                                                                                                                                                                                                                   |
| `checkedItem` | `int`: specifies which item is checked. If -1 no items are checked. <br />                                                                                                                                                                                                |
| `labelColumn` | `String`: The column name on the cursor containing the string to display in the label. <br />                                                                                                                                                                             |
| `listener`    | `DialogInterface.OnClickListener`: notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setSingleChoiceItems

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

```
AlertDialog.Builder setSingleChoiceItems (CharSequence[] items, 
                int checkedItem, 
                DialogInterface.OnClickListener listener)
```

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. The list will have a check mark displayed to the right of the text for the checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog.

<br />

|                                                                                                                                        Parameters                                                                                                                                        ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `items`       | `CharSequence`: the items to be displayed. <br />                                                                                                                                                                                                                         |
| `checkedItem` | `int`: specifies which item is checked. If -1 no items are checked. <br />                                                                                                                                                                                                |
| `listener`    | `DialogInterface.OnClickListener`: notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setTitle

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

```
AlertDialog.Builder setTitle (CharSequence title)
```

Set the title displayed in the[Dialog](https://developer.android.com/reference/android/app/Dialog.html).

<br />

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

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setTitle

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

```
AlertDialog.Builder setTitle (int titleId)
```

Set the title using the given resource id.

<br />

|       Parameters        ||
|-----------|--------------|
| `titleId` | `int` <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setView

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

```
AlertDialog.Builder setView (int layoutResId)
```

Set a custom view resource to be the contents of the Dialog. The resource will be inflated, adding all top-level views to the screen.

<br />

|                        Parameters                        ||
|---------------|-------------------------------------------|
| `layoutResId` | `int`: Resource ID to be inflated. <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### setView

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

```
AlertDialog.Builder setView (View view)
```

Sets a custom view to be the contents of the alert dialog.

When using a pre-Holo theme, if the supplied view is an instance of a[ListView](https://developer.android.com/reference/android/widget/ListView.html)then the light background will be used.

**Note:** To ensure consistent styling, the custom view should be inflated or constructed using the alert dialog's themed context obtained via[getContext()](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder#getContext()).

<br />

|                                 Parameters                                 ||
|--------|--------------------------------------------------------------------|
| `view` | `View`: the view to use as the contents of the alert dialog <br /> |

|                                                                                       Returns                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [AlertDialog.Builder](https://developer.android.com/reference/android/support/v7/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### show

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

```
AlertDialog show ()
```

Creates an[AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog)with the arguments supplied to this builder and immediately displays the dialog.

Calling this method is functionally identical to:  

```
     AlertDialog dialog = builder.create();
     dialog.show();
 
```

<br />

<br />

|                                              Returns                                              ||
|-------------------------------------------------------------------------------------------|--------|
| [AlertDialog](https://developer.android.com/reference/android/support/v7/app/AlertDialog) | <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)