MaterialAlertDialogBuilder

public class MaterialAlertDialogBuilder
extends AlertDialog.Builder

java.lang.Object
   ↳ androidx.appcompat.app.AlertDialog.Builder
     ↳ com.google.android.material.dialog.MaterialAlertDialogBuilder


An extension of AlertDialog.Builder for use with a Material theme (e.g., Theme.MaterialComponents).

This Builder must be used in order for AlertDialog objects to respond to color and shape theming provided by Material themes.

The type of dialog returned is still an AlertDialog; there is no specific Material implementation of AlertDialog.

Summary

Public constructors

MaterialAlertDialogBuilder(Context context)
MaterialAlertDialogBuilder(Context context, int overrideThemeResId)

Public methods

AlertDialog create()
Drawable getBackground()
MaterialAlertDialogBuilder setAdapter(ListAdapter adapter, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setBackground(Drawable background)
MaterialAlertDialogBuilder setBackgroundInsetBottom(int backgroundInsetBottom)
MaterialAlertDialogBuilder setBackgroundInsetEnd(int backgroundInsetEnd)
MaterialAlertDialogBuilder setBackgroundInsetStart(int backgroundInsetStart)
MaterialAlertDialogBuilder setBackgroundInsetTop(int backgroundInsetTop)
MaterialAlertDialogBuilder setCancelable(boolean cancelable)
MaterialAlertDialogBuilder setCursor(Cursor cursor, DialogInterface.OnClickListener listener, String labelColumn)
MaterialAlertDialogBuilder setCustomTitle(View customTitleView)
MaterialAlertDialogBuilder setIcon(Drawable icon)
MaterialAlertDialogBuilder setIcon(int iconId)
MaterialAlertDialogBuilder setIconAttribute(int attrId)
MaterialAlertDialogBuilder setItems(int itemsId, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setItems(CharSequence[] items, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setMessage(int messageId)
MaterialAlertDialogBuilder setMessage(CharSequence message)
MaterialAlertDialogBuilder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener)
MaterialAlertDialogBuilder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, DialogInterface.OnMultiChoiceClickListener listener)
MaterialAlertDialogBuilder setMultiChoiceItems(int itemsId, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener)
MaterialAlertDialogBuilder setNegativeButton(CharSequence text, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setNegativeButton(int textId, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setNegativeButtonIcon(Drawable icon)
MaterialAlertDialogBuilder setNeutralButton(CharSequence text, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setNeutralButton(int textId, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setNeutralButtonIcon(Drawable icon)
MaterialAlertDialogBuilder setOnCancelListener(DialogInterface.OnCancelListener onCancelListener)
MaterialAlertDialogBuilder setOnDismissListener(DialogInterface.OnDismissListener onDismissListener)
MaterialAlertDialogBuilder setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener)
MaterialAlertDialogBuilder setOnKeyListener(DialogInterface.OnKeyListener onKeyListener)
MaterialAlertDialogBuilder setPositiveButton(int textId, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setPositiveButtonIcon(Drawable icon)
MaterialAlertDialogBuilder setSingleChoiceItems(int itemsId, int checkedItem, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setSingleChoiceItems(ListAdapter adapter, int checkedItem, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setSingleChoiceItems(Cursor cursor, int checkedItem, String labelColumn, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setSingleChoiceItems(CharSequence[] items, int checkedItem, DialogInterface.OnClickListener listener)
MaterialAlertDialogBuilder setTitle(CharSequence title)
MaterialAlertDialogBuilder setTitle(int titleId)
MaterialAlertDialogBuilder setView(int layoutResId)
MaterialAlertDialogBuilder setView(View view)

Inherited methods

From class androidx.appcompat.app.AlertDialog.Builder
From class java.lang.Object

Public constructors

MaterialAlertDialogBuilder

MaterialAlertDialogBuilder (Context context)

Parameters
context Context

MaterialAlertDialogBuilder

MaterialAlertDialogBuilder (Context context, 
                int overrideThemeResId)

Parameters
context Context

overrideThemeResId int

Public methods

create

AlertDialog create ()

Returns
AlertDialog

getBackground

Drawable getBackground ()

Returns
Drawable

setAdapter

MaterialAlertDialogBuilder setAdapter (ListAdapter adapter, 
                DialogInterface.OnClickListener listener)

Parameters
adapter ListAdapter

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setBackground

MaterialAlertDialogBuilder setBackground (Drawable background)

Parameters
background Drawable

Returns
MaterialAlertDialogBuilder

setBackgroundInsetBottom

MaterialAlertDialogBuilder setBackgroundInsetBottom (int backgroundInsetBottom)

Parameters
backgroundInsetBottom int

Returns
MaterialAlertDialogBuilder

setBackgroundInsetEnd

MaterialAlertDialogBuilder setBackgroundInsetEnd (int backgroundInsetEnd)

Parameters
backgroundInsetEnd int

Returns
MaterialAlertDialogBuilder

setBackgroundInsetStart

MaterialAlertDialogBuilder setBackgroundInsetStart (int backgroundInsetStart)

Parameters
backgroundInsetStart int

Returns
MaterialAlertDialogBuilder

setBackgroundInsetTop

MaterialAlertDialogBuilder setBackgroundInsetTop (int backgroundInsetTop)

Parameters
backgroundInsetTop int

Returns
MaterialAlertDialogBuilder

setCancelable

MaterialAlertDialogBuilder setCancelable (boolean cancelable)

Parameters
cancelable boolean

Returns
MaterialAlertDialogBuilder

setCursor

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

Parameters
cursor Cursor

listener DialogInterface.OnClickListener

labelColumn String

Returns
MaterialAlertDialogBuilder

setCustomTitle

MaterialAlertDialogBuilder setCustomTitle (View customTitleView)

Parameters
customTitleView View

Returns
MaterialAlertDialogBuilder

setIcon

MaterialAlertDialogBuilder setIcon (Drawable icon)

Parameters
icon Drawable

Returns
MaterialAlertDialogBuilder

setIcon

MaterialAlertDialogBuilder setIcon (int iconId)

Parameters
iconId int

Returns
MaterialAlertDialogBuilder

setIconAttribute

MaterialAlertDialogBuilder setIconAttribute (int attrId)

Parameters
attrId int

Returns
MaterialAlertDialogBuilder

setItems

MaterialAlertDialogBuilder setItems (int itemsId, 
                DialogInterface.OnClickListener listener)

Parameters
itemsId int

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setItems

MaterialAlertDialogBuilder setItems (CharSequence[] items, 
                DialogInterface.OnClickListener listener)

Parameters
items CharSequence

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setMessage

MaterialAlertDialogBuilder setMessage (int messageId)

Parameters
messageId int

Returns
MaterialAlertDialogBuilder

setMessage

MaterialAlertDialogBuilder setMessage (CharSequence message)

Parameters
message CharSequence

Returns
MaterialAlertDialogBuilder

setMultiChoiceItems

MaterialAlertDialogBuilder setMultiChoiceItems (CharSequence[] items, 
                boolean[] checkedItems, 
                DialogInterface.OnMultiChoiceClickListener listener)

Parameters
items CharSequence

checkedItems boolean

listener DialogInterface.OnMultiChoiceClickListener

Returns
MaterialAlertDialogBuilder

setMultiChoiceItems

MaterialAlertDialogBuilder setMultiChoiceItems (Cursor cursor, 
                String isCheckedColumn, 
                String labelColumn, 
                DialogInterface.OnMultiChoiceClickListener listener)

Parameters
cursor Cursor

isCheckedColumn String

labelColumn String

listener DialogInterface.OnMultiChoiceClickListener

Returns
MaterialAlertDialogBuilder

setMultiChoiceItems

MaterialAlertDialogBuilder setMultiChoiceItems (int itemsId, 
                boolean[] checkedItems, 
                DialogInterface.OnMultiChoiceClickListener listener)

Parameters
itemsId int

checkedItems boolean

listener DialogInterface.OnMultiChoiceClickListener

Returns
MaterialAlertDialogBuilder

setNegativeButton

MaterialAlertDialogBuilder setNegativeButton (CharSequence text, 
                DialogInterface.OnClickListener listener)

Parameters
text CharSequence

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setNegativeButton

MaterialAlertDialogBuilder setNegativeButton (int textId, 
                DialogInterface.OnClickListener listener)

Parameters
textId int

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setNegativeButtonIcon

MaterialAlertDialogBuilder setNegativeButtonIcon (Drawable icon)

Parameters
icon Drawable

Returns
MaterialAlertDialogBuilder

setNeutralButton

MaterialAlertDialogBuilder setNeutralButton (CharSequence text, 
                DialogInterface.OnClickListener listener)

Parameters
text CharSequence

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setNeutralButton

MaterialAlertDialogBuilder setNeutralButton (int textId, 
                DialogInterface.OnClickListener listener)

Parameters
textId int

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setNeutralButtonIcon

MaterialAlertDialogBuilder setNeutralButtonIcon (Drawable icon)

Parameters
icon Drawable

Returns
MaterialAlertDialogBuilder

setOnCancelListener

MaterialAlertDialogBuilder setOnCancelListener (DialogInterface.OnCancelListener onCancelListener)

Parameters
onCancelListener DialogInterface.OnCancelListener

Returns
MaterialAlertDialogBuilder

setOnDismissListener

MaterialAlertDialogBuilder setOnDismissListener (DialogInterface.OnDismissListener onDismissListener)

Parameters
onDismissListener DialogInterface.OnDismissListener

Returns
MaterialAlertDialogBuilder

setOnItemSelectedListener

MaterialAlertDialogBuilder setOnItemSelectedListener (AdapterView.OnItemSelectedListener listener)

Parameters
listener AdapterView.OnItemSelectedListener

Returns
MaterialAlertDialogBuilder

setOnKeyListener

MaterialAlertDialogBuilder setOnKeyListener (DialogInterface.OnKeyListener onKeyListener)

Parameters
onKeyListener DialogInterface.OnKeyListener

Returns
MaterialAlertDialogBuilder

setPositiveButton

MaterialAlertDialogBuilder setPositiveButton (int textId, 
                DialogInterface.OnClickListener listener)

Parameters
textId int

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setPositiveButton

MaterialAlertDialogBuilder setPositiveButton (CharSequence text, 
                DialogInterface.OnClickListener listener)

Parameters
text CharSequence

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setPositiveButtonIcon

MaterialAlertDialogBuilder setPositiveButtonIcon (Drawable icon)

Parameters
icon Drawable

Returns
MaterialAlertDialogBuilder

setSingleChoiceItems

MaterialAlertDialogBuilder setSingleChoiceItems (int itemsId, 
                int checkedItem, 
                DialogInterface.OnClickListener listener)

Parameters
itemsId int

checkedItem int

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setSingleChoiceItems

MaterialAlertDialogBuilder setSingleChoiceItems (ListAdapter adapter, 
                int checkedItem, 
                DialogInterface.OnClickListener listener)

Parameters
adapter ListAdapter

checkedItem int

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setSingleChoiceItems

MaterialAlertDialogBuilder setSingleChoiceItems (Cursor cursor, 
                int checkedItem, 
                String labelColumn, 
                DialogInterface.OnClickListener listener)

Parameters
cursor Cursor

checkedItem int

labelColumn String

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setSingleChoiceItems

MaterialAlertDialogBuilder setSingleChoiceItems (CharSequence[] items, 
                int checkedItem, 
                DialogInterface.OnClickListener listener)

Parameters
items CharSequence

checkedItem int

listener DialogInterface.OnClickListener

Returns
MaterialAlertDialogBuilder

setTitle

MaterialAlertDialogBuilder setTitle (CharSequence title)

Parameters
title CharSequence

Returns
MaterialAlertDialogBuilder

setTitle

MaterialAlertDialogBuilder setTitle (int titleId)

Parameters
titleId int

Returns
MaterialAlertDialogBuilder

setView

MaterialAlertDialogBuilder setView (int layoutResId)

Parameters
layoutResId int

Returns
MaterialAlertDialogBuilder

setView

MaterialAlertDialogBuilder setView (View view)

Parameters
view View

Returns
MaterialAlertDialogBuilder