# AlertDialog.Builder

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/app/AlertDialog.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/app/AlertDialog.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/app/AlertDialog.Builder#inhmethods)  

# AlertDialog.Builder

*** ** * ** ***

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

`
public
static


class
AlertDialog.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

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

<br />

*** ** * ** ***

## Summary

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

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

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

```
public 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[R.attr.alertDialogTheme](https://developer.android.com/reference/android/R.attr#alertDialogTheme)within the parent`context`'s theme.

<br />

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

### Builder

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

```
public 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[R.style.Theme_Material_Dialog](https://developer.android.com/reference/android/R.style#Theme_Material_Dialog), to replace all attributes in the parent`context`'s theme including primary and accent colors.

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

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

<br />

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

## Public methods

### create

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

```
public AlertDialog create ()
```

Creates an[AlertDialog](https://developer.android.com/reference/android/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/app/AlertDialog.Builder#show())may be called instead to both create and display the dialog.

<br />

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

### getContext

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

```
public Context getContext ()
```

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

### setAdapter

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

```
public 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), 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)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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setCancelable

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setCursor

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

```
public 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), 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)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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setCustomTitle

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

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

Set the title using the custom view`customTitleView`.

The methods[setTitle(int)](https://developer.android.com/reference/android/app/AlertDialog.Builder#setTitle(int))and[setIcon(int)](https://developer.android.com/reference/android/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/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/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### setIcon

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

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

Set the[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable)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/app/AlertDialog.Builder#getContext()).

<br />

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

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

### setIcon

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

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

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

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

<br />

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

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

### setIconAttribute

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

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

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

Takes precedence over values set using[setIcon(int)](https://developer.android.com/reference/android/app/AlertDialog.Builder#setIcon(int))or[setIcon(android.graphics.drawable.Drawable)](https://developer.android.com/reference/android/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/app/AlertDialog.Builder) | <br /> |

### setInverseBackgroundForced

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

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

<br />

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

Sets the alert 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/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### setItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMessage

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMessage

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

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

Set the message to display.

<br />

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

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

### setMultiChoiceItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMultiChoiceItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setMultiChoiceItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setNegativeButton

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

```
public 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)to use. <br /> |

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

### setNegativeButton

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

```
public 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)to use. <br /> |

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

### setNeutralButton

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

```
public 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)to use. <br /> |

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

### setNeutralButton

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

```
public 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)to use. <br /> |

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

### setOnCancelListener

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

```
public 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/app/AlertDialog.Builder#setOnDismissListener(android.content.DialogInterface.OnDismissListener)).

<br />

<br />

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

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

**See also:**

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

### setOnDismissListener

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setOnItemSelectedListener

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

```
public 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/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

**See also:**

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

### setOnKeyListener

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setPositiveButton

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

```
public 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)to use. <br /> |

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

### setPositiveButton

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

```
public 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)to use. <br /> |

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

### setSingleChoiceItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setSingleChoiceItems

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

```
public 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)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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setSingleChoiceItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setSingleChoiceItems

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setTitle

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

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

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

<br />

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

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

### setTitle

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

```
public 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/app/AlertDialog.Builder) | This Builder object to allow for chaining of calls to set methods <br /> |

### setView

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

```
public 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/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### setView

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

```
public 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)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/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/app/AlertDialog.Builder) | this Builder object to allow for chaining of calls to set methods <br /> |

### show

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

```
public AlertDialog show ()
```

Creates an[AlertDialog](https://developer.android.com/reference/android/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/app/AlertDialog) | <br /> |