# AlertDialog.Builder

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

*** ** * ** ***

<br />

```
class AlertDialog.Builder
```

<br />

*** ** * ** ***

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#Builder(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Creates a builder for an alert dialog that uses the default alert dialog theme. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#Builder(android.content.Context,int)(context: https://developer.android.com/reference/android/content/Context.html, themeResId: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a builder for an alert dialog that uses an explicit theme resource. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#create()()` Creates an `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog` with the arguments supplied to this builder. |
| `https://developer.android.com/reference/android/content/Context.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#getContext()()` Returns a `https://developer.android.com/reference/android/content/Context.html` with the appropriate theme for dialogs created by this Builder. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setAdapter(android.widget.ListAdapter,android.content.DialogInterface.OnClickListener)( adapter: https://developer.android.com/reference/android/widget/ListAdapter.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Set a list of items, which are supplied by the given `https://developer.android.com/reference/android/widget/ListAdapter.html`, to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setCancelable(boolean)(cancelable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether the dialog is cancelable or not. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setCursor(android.database.Cursor,android.content.DialogInterface.OnClickListener,java.lang.String)( cursor: https://developer.android.com/reference/android/database/Cursor.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!, labelColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html! )` Set a list of items, which are supplied by the given `https://developer.android.com/reference/android/database/Cursor.html`, to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setCustomTitle(android.view.View)(customTitleView: https://developer.android.com/reference/android/view/View.html?)` Set the title using the custom view `customTitleView`. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setIcon(android.graphics.drawable.Drawable)(icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?)` Set the `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` to be used in the title. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setIcon(int)(iconId: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set the resource id of the `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` to be used in the title. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setIconAttribute(int)(attrId: @https://developer.android.com/reference/kotlin/androidx/annotation/AttrRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set an icon as supplied by a theme attribute. e.g. `https://developer.android.com/reference/android/R.attr.html#alertDialogIcon`. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `[setInverseBackgroundForced](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setInverseBackgroundForced(boolean))(useInverseBackground: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` **This function is deprecated.** This flag is only used for pre-Material themes. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setItems(java.lang.CharSequence[],android.content.DialogInterface.OnClickListener)( items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setItems(int,android.content.DialogInterface.OnClickListener)(itemsId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!)` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setMessage(java.lang.CharSequence)(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)` Set the message to display. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setMessage(int)(messageId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set the message to display using the given resource id. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setMultiChoiceItems(java.lang.CharSequence[],boolean[],android.content.DialogInterface.OnMultiChoiceClickListener)( items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!, checkedItems: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setMultiChoiceItems(int,boolean[],android.content.DialogInterface.OnMultiChoiceClickListener)( itemsId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, checkedItems: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setMultiChoiceItems(android.database.Cursor,java.lang.String,java.lang.String,android.content.DialogInterface.OnMultiChoiceClickListener)( cursor: https://developer.android.com/reference/android/database/Cursor.html!, isCheckedColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, labelColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setNegativeButton(java.lang.CharSequence,android.content.DialogInterface.OnClickListener)( text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Set a listener to be invoked when the negative button of the dialog is pressed. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setNegativeButton(int,android.content.DialogInterface.OnClickListener)( textId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Set a listener to be invoked when the negative button of the dialog is pressed. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setNegativeButtonIcon(android.graphics.drawable.Drawable)(icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!)` Set an icon to be displayed for the negative button. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setNeutralButton(java.lang.CharSequence,android.content.DialogInterface.OnClickListener)( text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Set a listener to be invoked when the neutral button of the dialog is pressed. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setNeutralButton(int,android.content.DialogInterface.OnClickListener)( textId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Set a listener to be invoked when the neutral button of the dialog is pressed. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setNeutralButtonIcon(android.graphics.drawable.Drawable)(icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!)` Set an icon to be displayed for the neutral button. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setOnCancelListener(android.content.DialogInterface.OnCancelListener)(onCancelListener: https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener.html!)` Sets the callback that will be called if the dialog is canceled. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setOnDismissListener(android.content.DialogInterface.OnDismissListener)( onDismissListener: https://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html! )` Sets the callback that will be called when the dialog is dismissed for any reason. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)(listener: https://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html!)` Sets a listener to be invoked when an item in the list is selected. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setOnKeyListener(android.content.DialogInterface.OnKeyListener)(onKeyListener: https://developer.android.com/reference/android/content/DialogInterface.OnKeyListener.html!)` Sets the callback that will be called if a key is dispatched to the dialog. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setPositiveButton(java.lang.CharSequence,android.content.DialogInterface.OnClickListener)( text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Set a listener to be invoked when the positive button of the dialog is pressed. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setPositiveButton(int,android.content.DialogInterface.OnClickListener)( textId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` Set a listener to be invoked when the positive button of the dialog is pressed. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setPositiveButtonIcon(android.graphics.drawable.Drawable)(icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!)` Set an icon to be displayed for the positive button. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setSingleChoiceItems(android.widget.ListAdapter,int,android.content.DialogInterface.OnClickListener)( adapter: https://developer.android.com/reference/android/widget/ListAdapter.html!, checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setSingleChoiceItems(java.lang.CharSequence[],int,android.content.DialogInterface.OnClickListener)( items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!, checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setSingleChoiceItems(int,int,android.content.DialogInterface.OnClickListener)( itemsId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setSingleChoiceItems(android.database.Cursor,int,java.lang.String,android.content.DialogInterface.OnClickListener)( cursor: https://developer.android.com/reference/android/database/Cursor.html!, checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, labelColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html! )` 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. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)` Set the title displayed in the `https://developer.android.com/reference/android/app/Dialog.html`. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setTitle(int)(titleId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set the title using the given resource id. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setView(int)(layoutResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Inflates a custom view resource inside the dialog, below the message and above the buttons. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html!)` Sets a custom view to be the contents of the alert dialog. |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#show()()` Creates an `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog` with the arguments supplied to this builder and immediately displays the dialog. |

## Public constructors

### Builder

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

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

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | the parent context |

### Builder

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

```
Builder(context: Context, themeResId: @StyleRes Int)
```

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

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

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

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | the parent context |
| `themeResId: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the resource ID of the theme against which to inflate this dialog, or `0` to use the parent `context`'s default alert dialog theme |

## Public functions

### create

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

```
fun create(): AlertDialog
```

Creates an `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog` with the arguments supplied to this builder.

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

### getContext

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

```
fun getContext(): Context
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html` | A Context for built Dialogs. |

### setAdapter

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

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

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

| Parameters |
|---|---|
| `adapter: https://developer.android.com/reference/android/widget/ListAdapter.html!` | The `https://developer.android.com/reference/android/widget/ListAdapter.html` to supply the list of items |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The listener that will be called when an item is clicked. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setCancelable

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

```
fun setCancelable(cancelable: Boolean): AlertDialog.Builder!
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setCursor

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

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

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

| Parameters |
|---|---|
| `cursor: https://developer.android.com/reference/android/database/Cursor.html!` | The `https://developer.android.com/reference/android/database/Cursor.html` to supply the list of items |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The listener that will be called when an item is clicked. |
| `labelColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The column name on the cursor containing the string to display in the label. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setCustomTitle

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

```
fun setCustomTitle(customTitleView: View?): AlertDialog.Builder!
```

Set the title using the custom view `customTitleView`.

The methods `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setTitle(int)` and `https://developer.android.com/reference/kotlin/androidx/appcompat/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 `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#getContext()`.

| Parameters |
|---|---|
| `customTitleView: https://developer.android.com/reference/android/view/View.html?` | the custom view to use as the title |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | this Builder object to allow for chaining of calls to set methods |

### setIcon

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

```
fun setIcon(icon: Drawable?): AlertDialog.Builder!
```

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | this Builder object to allow for chaining of calls to set methods |

### setIcon

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

```
fun setIcon(iconId: @DrawableRes Int): AlertDialog.Builder!
```

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setIconAttribute

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

```
fun setIconAttribute(attrId: @AttrRes Int): AlertDialog.Builder!
```

Set an icon as supplied by a theme attribute. e.g. `https://developer.android.com/reference/android/R.attr.html#alertDialogIcon`.

Takes precedence over values set using `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setIcon(int)` or `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setIcon(android.graphics.drawable.Drawable)`.

| Parameters |
|---|---|
| `attrId: @https://developer.android.com/reference/kotlin/androidx/annotation/AttrRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | ID of a theme attribute that points to a drawable resource. |

### setInverseBackgroundForced

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

```
fun [setInverseBackgroundForced](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setInverseBackgroundForced(boolean))(useInverseBackground: Boolean): AlertDialog.Builder!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> This flag is only used for pre-Material themes. Instead, specify the window background using on the alert dialog theme.

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

| Parameters |
|---|---|
| `useInverseBackground: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to use the inverse background |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setItems

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

```
fun setItems(
    items: Array<CharSequence!>!,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setItems

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

```
fun setItems(itemsId: @ArrayRes Int, listener: DialogInterface.OnClickListener!): AlertDialog.Builder!
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setMessage

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

```
fun setMessage(message: CharSequence?): AlertDialog.Builder!
```

Set the message to display.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setMessage

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

```
fun setMessage(messageId: @StringRes Int): AlertDialog.Builder!
```

Set the message to display using the given resource id.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setMultiChoiceItems

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

```
fun setMultiChoiceItems(
    items: Array<CharSequence!>!,
    checkedItems: BooleanArray<Boolean>!,
    listener: DialogInterface.OnMultiChoiceClickListener!
): AlertDialog.Builder!
```

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.

| Parameters |
|---|---|
| `items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | the text of the items to be displayed in the list. |
| `checkedItems: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>!` | 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. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html!` | 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. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setMultiChoiceItems

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

```
fun setMultiChoiceItems(
    itemsId: @ArrayRes Int,
    checkedItems: BooleanArray<Boolean>!,
    listener: DialogInterface.OnMultiChoiceClickListener!
): AlertDialog.Builder!
```

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.

| Parameters |
|---|---|
| `itemsId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the resource id of an array i.e. R.array.foo |
| `checkedItems: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>!` | 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. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html!` | 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. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setMultiChoiceItems

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

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

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.

| Parameters |
|---|---|
| `cursor: https://developer.android.com/reference/android/database/Cursor.html!` | the cursor used to provide the items. |
| `isCheckedColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | 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. |
| `labelColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The column name on the cursor containing the string to display in the label. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnMultiChoiceClickListener.html!` | 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. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setNegativeButton

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

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

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

| Parameters |
|---|---|
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The text to display in the negative button |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setNegativeButton

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

```
fun setNegativeButton(
    textId: @StringRes Int,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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

| Parameters |
|---|---|
| `textId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The resource id of the text to display in the negative button |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setNegativeButtonIcon

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

```
fun setNegativeButtonIcon(icon: Drawable!): AlertDialog.Builder!
```

Set an icon to be displayed for the negative button.

| Parameters |
|---|---|
| `icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!` | The icon to be displayed |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setNeutralButton

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

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

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

| Parameters |
|---|---|
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The text to display in the neutral button |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setNeutralButton

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

```
fun setNeutralButton(
    textId: @StringRes Int,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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

| Parameters |
|---|---|
| `textId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The resource id of the text to display in the neutral button |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setNeutralButtonIcon

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

```
fun setNeutralButtonIcon(icon: Drawable!): AlertDialog.Builder!
```

Set an icon to be displayed for the neutral button.

| Parameters |
|---|---|
| `icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!` | The icon to be displayed |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setOnCancelListener

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

```
fun setOnCancelListener(onCancelListener: DialogInterface.OnCancelListener!): AlertDialog.Builder!
```

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 `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setOnDismissListener(android.content.DialogInterface.OnDismissListener)`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setCancelable(boolean)` |   |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder#setOnDismissListener(android.content.DialogInterface.OnDismissListener)` |   |

### setOnDismissListener

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

```
fun setOnDismissListener(
    onDismissListener: DialogInterface.OnDismissListener!
): AlertDialog.Builder!
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setOnItemSelectedListener

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

```
fun setOnItemSelectedListener(listener: AdapterView.OnItemSelectedListener!): AlertDialog.Builder!
```

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

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html!` | the listener to be invoked |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | this Builder object to allow for chaining of calls to set methods |

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/AdapterView.html#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)` |   |

### setOnKeyListener

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

```
fun setOnKeyListener(onKeyListener: DialogInterface.OnKeyListener!): AlertDialog.Builder!
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setPositiveButton

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

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

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

| Parameters |
|---|---|
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | The text to display in the positive button |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setPositiveButton

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

```
fun setPositiveButton(
    textId: @StringRes Int,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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

| Parameters |
|---|---|
| `textId: @https://developer.android.com/reference/kotlin/androidx/annotation/StringRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The resource id of the text to display in the positive button |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | The `https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html` to use. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setPositiveButtonIcon

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

```
fun setPositiveButtonIcon(icon: Drawable!): AlertDialog.Builder!
```

Set an icon to be displayed for the positive button.

| Parameters |
|---|---|
| `icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html!` | The icon to be displayed |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setSingleChoiceItems

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

```
fun setSingleChoiceItems(
    adapter: ListAdapter!,
    checkedItem: Int,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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.

| Parameters |
|---|---|
| `adapter: https://developer.android.com/reference/android/widget/ListAdapter.html!` | The `https://developer.android.com/reference/android/widget/ListAdapter.html` to supply the list of items |
| `checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | specifies which item is checked. If -1 no items are checked. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | 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. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setSingleChoiceItems

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

```
fun setSingleChoiceItems(
    items: Array<CharSequence!>!,
    checkedItem: Int,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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.

| Parameters |
|---|---|
| `items: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | the items to be displayed. |
| `checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | specifies which item is checked. If -1 no items are checked. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | 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. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setSingleChoiceItems

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

```
fun setSingleChoiceItems(
    itemsId: @ArrayRes Int,
    checkedItem: Int,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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.

| Parameters |
|---|---|
| `itemsId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the resource id of an array i.e. R.array.foo |
| `checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | specifies which item is checked. If -1 no items are checked. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | 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. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setSingleChoiceItems

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

```
fun setSingleChoiceItems(
    cursor: Cursor!,
    checkedItem: Int,
    labelColumn: String!,
    listener: DialogInterface.OnClickListener!
): AlertDialog.Builder!
```

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.

| Parameters |
|---|---|
| `cursor: https://developer.android.com/reference/android/database/Cursor.html!` | the cursor to retrieve the items from. |
| `checkedItem: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | specifies which item is checked. If -1 no items are checked. |
| `labelColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The column name on the cursor containing the string to display in the label. |
| `listener: https://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html!` | 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. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setTitle

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

```
fun setTitle(title: CharSequence?): AlertDialog.Builder!
```

Set the title displayed in the `https://developer.android.com/reference/android/app/Dialog.html`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setTitle

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

```
fun setTitle(titleId: @StringRes Int): AlertDialog.Builder!
```

Set the title using the given resource id.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | This Builder object to allow for chaining of calls to set methods |

### setView

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

```
fun setView(layoutResId: Int): AlertDialog.Builder!
```

Inflates a custom view resource inside the dialog, below the message and above the buttons. If none of the other parts of the dialog are made visible, the custom view occupies the entire view. Because the view is inflated inside the parent dialog's view, take care not to define conflicting resource IDs.

| Parameters |
|---|---|
| `layoutResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Resource ID to be inflated. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | this Builder object to allow for chaining of calls to set methods |

### setView

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

```
fun setView(view: View!): AlertDialog.Builder!
```

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 `https://developer.android.com/reference/android/widget/ListView.html` then the light background will be used.

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

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/view/View.html!` | the view to use as the contents of the alert dialog |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog.Builder!` | this Builder object to allow for chaining of calls to set methods |

### show

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

```
fun show(): AlertDialog!
```

Creates an `https://developer.android.com/reference/kotlin/androidx/appcompat/app/AlertDialog` with the arguments supplied to this builder and immediately displays the dialog.

Calling this method is functionally identical to:

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