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
.
For more information, see the component developer guidance and design guidelines.
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 | |
---|---|
Public constructors
MaterialAlertDialogBuilder
public MaterialAlertDialogBuilder (Context context)
Parameters | |
---|---|
context |
Context |
MaterialAlertDialogBuilder
public MaterialAlertDialogBuilder (Context context, int overrideThemeResId)
Parameters | |
---|---|
context |
Context |
overrideThemeResId |
int |
Public methods
create
public AlertDialog create ()
Returns | |
---|---|
AlertDialog |
getBackground
public Drawable getBackground ()
Returns | |
---|---|
Drawable |
setAdapter
public MaterialAlertDialogBuilder setAdapter (ListAdapter adapter, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
adapter |
ListAdapter |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setBackground
public MaterialAlertDialogBuilder setBackground (Drawable background)
Parameters | |
---|---|
background |
Drawable |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setBackgroundInsetBottom
public MaterialAlertDialogBuilder setBackgroundInsetBottom (int backgroundInsetBottom)
Parameters | |
---|---|
backgroundInsetBottom |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setBackgroundInsetEnd
public MaterialAlertDialogBuilder setBackgroundInsetEnd (int backgroundInsetEnd)
Parameters | |
---|---|
backgroundInsetEnd |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setBackgroundInsetStart
public MaterialAlertDialogBuilder setBackgroundInsetStart (int backgroundInsetStart)
Parameters | |
---|---|
backgroundInsetStart |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setBackgroundInsetTop
public MaterialAlertDialogBuilder setBackgroundInsetTop (int backgroundInsetTop)
Parameters | |
---|---|
backgroundInsetTop |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setCancelable
public MaterialAlertDialogBuilder setCancelable (boolean cancelable)
Parameters | |
---|---|
cancelable |
boolean |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setCursor
public MaterialAlertDialogBuilder setCursor (Cursor cursor, DialogInterface.OnClickListener listener, String labelColumn)
Parameters | |
---|---|
cursor |
Cursor |
listener |
DialogInterface.OnClickListener |
labelColumn |
String |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setCustomTitle
public MaterialAlertDialogBuilder setCustomTitle (View customTitleView)
Parameters | |
---|---|
customTitleView |
View |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setIcon
public MaterialAlertDialogBuilder setIcon (Drawable icon)
Parameters | |
---|---|
icon |
Drawable |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setIcon
public MaterialAlertDialogBuilder setIcon (int iconId)
Parameters | |
---|---|
iconId |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setIconAttribute
public MaterialAlertDialogBuilder setIconAttribute (int attrId)
Parameters | |
---|---|
attrId |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setItems
public MaterialAlertDialogBuilder setItems (int itemsId, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
itemsId |
int |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setItems
public MaterialAlertDialogBuilder setItems (CharSequence[] items, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
items |
CharSequence |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setMessage
public MaterialAlertDialogBuilder setMessage (int messageId)
Parameters | |
---|---|
messageId |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setMessage
public MaterialAlertDialogBuilder setMessage (CharSequence message)
Parameters | |
---|---|
message |
CharSequence |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setMultiChoiceItems
public MaterialAlertDialogBuilder setMultiChoiceItems (CharSequence[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener)
Parameters | |
---|---|
items |
CharSequence |
checkedItems |
boolean |
listener |
DialogInterface.OnMultiChoiceClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setMultiChoiceItems
public MaterialAlertDialogBuilder setMultiChoiceItems (Cursor cursor, String isCheckedColumn, String labelColumn, DialogInterface.OnMultiChoiceClickListener listener)
Parameters | |
---|---|
cursor |
Cursor |
isCheckedColumn |
String |
labelColumn |
String |
listener |
DialogInterface.OnMultiChoiceClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setMultiChoiceItems
public MaterialAlertDialogBuilder setMultiChoiceItems (int itemsId, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener)
Parameters | |
---|---|
itemsId |
int |
checkedItems |
boolean |
listener |
DialogInterface.OnMultiChoiceClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setNegativeButton
public MaterialAlertDialogBuilder setNegativeButton (CharSequence text, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
text |
CharSequence |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setNegativeButton
public MaterialAlertDialogBuilder setNegativeButton (int textId, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
textId |
int |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setNegativeButtonIcon
public MaterialAlertDialogBuilder setNegativeButtonIcon (Drawable icon)
Parameters | |
---|---|
icon |
Drawable |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setNeutralButton
public MaterialAlertDialogBuilder setNeutralButton (CharSequence text, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
text |
CharSequence |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setNeutralButton
public MaterialAlertDialogBuilder setNeutralButton (int textId, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
textId |
int |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setNeutralButtonIcon
public MaterialAlertDialogBuilder setNeutralButtonIcon (Drawable icon)
Parameters | |
---|---|
icon |
Drawable |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setOnCancelListener
public MaterialAlertDialogBuilder setOnCancelListener (DialogInterface.OnCancelListener onCancelListener)
Parameters | |
---|---|
onCancelListener |
DialogInterface.OnCancelListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setOnDismissListener
public MaterialAlertDialogBuilder setOnDismissListener (DialogInterface.OnDismissListener onDismissListener)
Parameters | |
---|---|
onDismissListener |
DialogInterface.OnDismissListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setOnItemSelectedListener
public MaterialAlertDialogBuilder setOnItemSelectedListener (AdapterView.OnItemSelectedListener listener)
Parameters | |
---|---|
listener |
AdapterView.OnItemSelectedListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setOnKeyListener
public MaterialAlertDialogBuilder setOnKeyListener (DialogInterface.OnKeyListener onKeyListener)
Parameters | |
---|---|
onKeyListener |
DialogInterface.OnKeyListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setPositiveButton
public MaterialAlertDialogBuilder setPositiveButton (int textId, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
textId |
int |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setPositiveButton
public MaterialAlertDialogBuilder setPositiveButton (CharSequence text, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
text |
CharSequence |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setPositiveButtonIcon
public MaterialAlertDialogBuilder setPositiveButtonIcon (Drawable icon)
Parameters | |
---|---|
icon |
Drawable |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setSingleChoiceItems
public MaterialAlertDialogBuilder setSingleChoiceItems (int itemsId, int checkedItem, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
itemsId |
int |
checkedItem |
int |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setSingleChoiceItems
public MaterialAlertDialogBuilder setSingleChoiceItems (ListAdapter adapter, int checkedItem, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
adapter |
ListAdapter |
checkedItem |
int |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setSingleChoiceItems
public MaterialAlertDialogBuilder setSingleChoiceItems (Cursor cursor, int checkedItem, String labelColumn, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
cursor |
Cursor |
checkedItem |
int |
labelColumn |
String |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setSingleChoiceItems
public MaterialAlertDialogBuilder setSingleChoiceItems (CharSequence[] items, int checkedItem, DialogInterface.OnClickListener listener)
Parameters | |
---|---|
items |
CharSequence |
checkedItem |
int |
listener |
DialogInterface.OnClickListener |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setTitle
public MaterialAlertDialogBuilder setTitle (CharSequence title)
Parameters | |
---|---|
title |
CharSequence |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setTitle
public MaterialAlertDialogBuilder setTitle (int titleId)
Parameters | |
---|---|
titleId |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setView
public MaterialAlertDialogBuilder setView (int layoutResId)
Parameters | |
---|---|
layoutResId |
int |
Returns | |
---|---|
MaterialAlertDialogBuilder |
setView
public MaterialAlertDialogBuilder setView (View view)
Parameters | |
---|---|
view |
View |
Returns | |
---|---|
MaterialAlertDialogBuilder |