AlertDialog.Builder

public static class AlertDialog.Builder
extends Object

java.lang.Object
   ↳ androidx.appcompat.app.AlertDialog.Builder


Summary

Public constructors

Builder(Context context)

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

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 is deprecated. 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)