added in version 24.1.0
belongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1

AlertDialog.Builder

public static class AlertDialog.Builder
extends Object

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


Summary

Public constructors

AlertDialog.Builder(Context context)

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

AlertDialog.Builder(Context context, int themeResId)

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

Public methods

AlertDialog create()

Creates an AlertDialog with the arguments supplied to this builder.

Context getContext()

Returns a Context with the appropriate theme for dialogs created by this Builder.

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

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

AlertDialog.Builder setCancelable(boolean cancelable)

Sets whether the dialog is cancelable or not.

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

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

AlertDialog.Builder setCustomTitle(View customTitleView)

Set the title using the custom view customTitleView.

AlertDialog.Builder setIcon(Drawable icon)

Set the Drawable to be used in the title.

AlertDialog.Builder setIcon(int iconId)

Set the resource id of the Drawable to be used in the title.

AlertDialog.Builder setIconAttribute(int attrId)

Set an icon as supplied by a theme attribute.

AlertDialog.Builder setInverseBackgroundForced(boolean useInverseBackground)

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

AlertDialog.Builder 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.

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.

AlertDialog.Builder setMessage(int messageId)

Set the message to display using the given resource id.

AlertDialog.Builder setMessage(CharSequence message)

Set the message to display.

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.

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.

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.

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

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

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

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

AlertDialog.Builder setNegativeButtonIcon(Drawable icon)

Set an icon to be displayed for the negative button.

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

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

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

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

AlertDialog.Builder setNeutralButtonIcon(Drawable icon)

Set an icon to be displayed for the neutral button.

AlertDialog.Builder setOnCancelListener(DialogInterface.OnCancelListener onCancelListener)

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

AlertDialog.Builder setOnDismissListener(DialogInterface.OnDismissListener onDismissListener)

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

AlertDialog.Builder setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener)

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

AlertDialog.Builder setOnKeyListener(DialogInterface.OnKeyListener onKeyListener)

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

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

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

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

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

AlertDialog.Builder setPositiveButtonIcon(Drawable icon)

Set an icon to be displayed for the positive button.

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.

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.

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.

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.

AlertDialog.Builder setTitle(CharSequence title)

Set the title displayed in the Dialog.

AlertDialog.Builder setTitle(int titleId)

Set the title using the given resource id.

AlertDialog.Builder setView(int layoutResId)

Set a custom view resource to be the contents of the Dialog.

AlertDialog.Builder setView(View view)

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

AlertDialog show()

Creates an AlertDialog with the arguments supplied to this builder and immediately displays the dialog.

Inherited methods

From class java.lang.Object

Public constructors

AlertDialog.Builder

added in version 24.1.0
AlertDialog.Builder (Context context)

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

The default alert dialog theme is defined by alertDialogTheme within the parent context's theme.

Parameters
context Context: the parent context

AlertDialog.Builder

added in version 24.1.0
AlertDialog.Builder (Context context, 
                int themeResId)

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

The specified theme resource (themeResId) is applied on top of the parent context's theme. It may be specified as a style resource containing a fully-populated theme, such as Theme_AppCompat_Dialog, to replace all attributes in the parent context's theme including primary and accent colors.

To preserve attributes such as primary and accent colors, the themeResId may instead be specified as an overlay theme such as ThemeOverlay_AppCompat_Dialog. This will override only the window attributes necessary to style the alert window as a dialog.

Alternatively, the themeResId may be specified as 0 to use the parent context's resolved value for alertDialogTheme.

Parameters
context Context: the parent context

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

Public methods

create

added in version 24.1.0
AlertDialog create ()

Creates an AlertDialog with the arguments supplied to this builder.

Calling this method does not display the dialog. If no additional processing is needed, show() may be called instead to both create and display the dialog.

Returns
AlertDialog

getContext

added in version 24.1.0
Context getContext ()

Returns a 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.

Returns
Context A Context for built Dialogs.

setAdapter

added in version 24.1.0
AlertDialog.Builder setAdapter (ListAdapter adapter, 
                DialogInterface.OnClickListener listener)

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

Parameters
adapter ListAdapter: The ListAdapter to supply the list of items

listener DialogInterface.OnClickListener: The listener that will be called when an item is clicked.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setCancelable

added in version 24.1.0
AlertDialog.Builder setCancelable (boolean cancelable)

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

Parameters
cancelable boolean

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setCursor

added in version 24.1.0
AlertDialog.Builder setCursor (Cursor cursor, 
                DialogInterface.OnClickListener listener, 
                String labelColumn)

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

Parameters
cursor Cursor: The Cursor to supply the list of items

listener DialogInterface.OnClickListener: The listener that will be called when an item is clicked.

labelColumn String: The column name on the cursor containing the string to display in the label.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setCustomTitle

added in version 24.1.0
AlertDialog.Builder setCustomTitle (View customTitleView)

Set the title using the custom view customTitleView.

The methods setTitle(int) and 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().

Parameters
customTitleView View: the custom view to use as the title

Returns
AlertDialog.Builder this Builder object to allow for chaining of calls to set methods

setIcon

added in version 24.1.0
AlertDialog.Builder setIcon (Drawable icon)

Set the 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().

Parameters
icon Drawable

Returns
AlertDialog.Builder this Builder object to allow for chaining of calls to set methods

setIcon

added in version 24.1.0
AlertDialog.Builder setIcon (int iconId)

Set the resource id of the Drawable to be used in the title.

Takes precedence over values set using setIcon(Drawable).

Parameters
iconId int

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setIconAttribute

added in version 24.1.0
AlertDialog.Builder setIconAttribute (int attrId)

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

Takes precedence over values set using setIcon(int) or setIcon(Drawable).

Parameters
attrId int: ID of a theme attribute that points to a drawable resource.

Returns
AlertDialog.Builder

setInverseBackgroundForced

added in version 24.1.0
AlertDialog.Builder setInverseBackgroundForced (boolean useInverseBackground)

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

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

Parameters
useInverseBackground boolean: Whether to use the inverse background

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setItems

added in version 24.1.0
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

Parameters
itemsId int

listener DialogInterface.OnClickListener

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setItems

added in version 24.1.0
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.

Parameters
items CharSequence

listener DialogInterface.OnClickListener

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setMessage

added in version 24.1.0
AlertDialog.Builder setMessage (int messageId)

Set the message to display using the given resource id.

Parameters
messageId int

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setMessage

added in version 24.1.0
AlertDialog.Builder setMessage (CharSequence message)

Set the message to display.

Parameters
message CharSequence

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setMultiChoiceItems

added in version 24.1.0
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.

Parameters
items CharSequence: the text of the items to be displayed in the list.

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.

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.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setMultiChoiceItems

added in version 24.1.0
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.

Parameters
cursor Cursor: the cursor used to provide the items.

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.

labelColumn String: The column name on the cursor containing the string to display in the label.

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.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setMultiChoiceItems

added in version 24.1.0
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.

Parameters
itemsId int: the resource id of an array i.e. R.array.foo

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.

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.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setNegativeButton

added in version 24.1.0
AlertDialog.Builder setNegativeButton (CharSequence text, 
                DialogInterface.OnClickListener listener)

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

Parameters
text CharSequence: The text to display in the negative button

listener DialogInterface.OnClickListener: The DialogInterface.OnClickListener to use.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setNegativeButton

added in version 24.1.0
AlertDialog.Builder setNegativeButton (int textId, 
                DialogInterface.OnClickListener listener)

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

Parameters
textId int: The resource id of the text to display in the negative button

listener DialogInterface.OnClickListener: The DialogInterface.OnClickListener to use.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setNegativeButtonIcon

added in version 27.1.0
AlertDialog.Builder setNegativeButtonIcon (Drawable icon)

Set an icon to be displayed for the negative button.

Parameters
icon Drawable: The icon to be displayed

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setNeutralButton

added in version 24.1.0
AlertDialog.Builder setNeutralButton (CharSequence text, 
                DialogInterface.OnClickListener listener)

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

Parameters
text CharSequence: The text to display in the neutral button

listener DialogInterface.OnClickListener: The DialogInterface.OnClickListener to use.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setNeutralButton

added in version 24.1.0
AlertDialog.Builder setNeutralButton (int textId, 
                DialogInterface.OnClickListener listener)

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

Parameters
textId int: The resource id of the text to display in the neutral button

listener DialogInterface.OnClickListener: The DialogInterface.OnClickListener to use.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setNeutralButtonIcon

added in version 27.1.0
AlertDialog.Builder setNeutralButtonIcon (Drawable icon)

Set an icon to be displayed for the neutral button.

Parameters
icon Drawable: The icon to be displayed

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setOnCancelListener

added in version 24.1.0
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.

Parameters
onCancelListener DialogInterface.OnCancelListener

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methodsThis Builder object to allow for chaining of calls to set methods

setOnDismissListener

added in version 24.1.0
AlertDialog.Builder setOnDismissListener (DialogInterface.OnDismissListener onDismissListener)

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

Parameters
onDismissListener DialogInterface.OnDismissListener

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setOnItemSelectedListener

added in version 24.1.0
AlertDialog.Builder setOnItemSelectedListener (AdapterView.OnItemSelectedListener listener)

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

Parameters
listener AdapterView.OnItemSelectedListener: the listener to be invoked

Returns
AlertDialog.Builder this Builder object to allow for chaining of calls to set methods

setOnKeyListener

added in version 24.1.0
AlertDialog.Builder setOnKeyListener (DialogInterface.OnKeyListener onKeyListener)

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

Parameters
onKeyListener DialogInterface.OnKeyListener

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setPositiveButton

added in version 24.1.0
AlertDialog.Builder setPositiveButton (int textId, 
                DialogInterface.OnClickListener listener)

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

Parameters
textId int: The resource id of the text to display in the positive button

listener DialogInterface.OnClickListener: The DialogInterface.OnClickListener to use.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setPositiveButton

added in version 24.1.0
AlertDialog.Builder setPositiveButton (CharSequence text, 
                DialogInterface.OnClickListener listener)

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

Parameters
text CharSequence: The text to display in the positive button

listener DialogInterface.OnClickListener: The DialogInterface.OnClickListener to use.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setPositiveButtonIcon

added in version 27.1.0
AlertDialog.Builder setPositiveButtonIcon (Drawable icon)

Set an icon to be displayed for the positive button.

Parameters
icon Drawable: The icon to be displayed

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setSingleChoiceItems

added in version 24.1.0
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.

Parameters
itemsId int: the resource id of an array i.e. R.array.foo

checkedItem int: specifies which item is checked. If -1 no items are checked.

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.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setSingleChoiceItems

added in version 24.1.0
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.

Parameters
adapter ListAdapter: The ListAdapter to supply the list of items

checkedItem int: specifies which item is checked. If -1 no items are checked.

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.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setSingleChoiceItems

added in version 24.1.0
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.

Parameters
cursor Cursor: the cursor to retrieve the items from.

checkedItem int: specifies which item is checked. If -1 no items are checked.

labelColumn String: The column name on the cursor containing the string to display in the label.

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.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setSingleChoiceItems

added in version 24.1.0
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.

Parameters
items CharSequence: the items to be displayed.

checkedItem int: specifies which item is checked. If -1 no items are checked.

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.

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setTitle

added in version 24.1.0
AlertDialog.Builder setTitle (CharSequence title)

Set the title displayed in the Dialog.

Parameters
title CharSequence

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setTitle

added in version 24.1.0
AlertDialog.Builder setTitle (int titleId)

Set the title using the given resource id.

Parameters
titleId int

Returns
AlertDialog.Builder This Builder object to allow for chaining of calls to set methods

setView

added in version 24.1.0
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.

Parameters
layoutResId int: Resource ID to be inflated.

Returns
AlertDialog.Builder this Builder object to allow for chaining of calls to set methods

setView

added in version 24.1.0
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 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().

Parameters
view View: the view to use as the contents of the alert dialog

Returns
AlertDialog.Builder this Builder object to allow for chaining of calls to set methods

show

added in version 24.1.0
AlertDialog show ()

Creates an 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();
 

Returns
AlertDialog