java.lang.Object | |
↳ | android.app.AlertDialog.Builder |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a builder for an alert dialog that uses the default alert
dialog theme.
| |||||||||||
Creates a builder for an alert dialog that uses an explicit theme
resource.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an
AlertDialog with the arguments supplied to this
builder.
| |||||||||||
Returns a
Context with the appropriate theme for dialogs created by this Builder.
| |||||||||||
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.
| |||||||||||
Sets whether the dialog is cancelable or not.
| |||||||||||
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.
| |||||||||||
Set the title using the custom view
customTitleView .
| |||||||||||
Set the
Drawable to be used in the title.
| |||||||||||
Set the resource id of the
Drawable to be used in the title.
| |||||||||||
Set an icon as supplied by a theme attribute.
| |||||||||||
This method was deprecated
in API level 23.
This flag is only used for pre-Material themes. Instead,
specify the window background using on the alert dialog
theme.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Set the message to display.
| |||||||||||
Set the message to display using the given resource id.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Set a listener to be invoked when the negative button of the dialog is pressed.
| |||||||||||
Set a listener to be invoked when the negative button of the dialog is pressed.
| |||||||||||
Set a listener to be invoked when the neutral button of the dialog is pressed.
| |||||||||||
Set a listener to be invoked when the neutral button of the dialog is pressed.
| |||||||||||
Sets the callback that will be called if the dialog is canceled.
| |||||||||||
Sets the callback that will be called when the dialog is dismissed for any reason.
| |||||||||||
Sets a listener to be invoked when an item in the list is selected.
| |||||||||||
Sets the callback that will be called if a key is dispatched to the dialog.
| |||||||||||
Set a listener to be invoked when the positive button of the dialog is pressed.
| |||||||||||
Set a listener to be invoked when the positive button of the dialog is pressed.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Set the title displayed in the
Dialog .
| |||||||||||
Set the title using the given resource id.
| |||||||||||
Set a custom view resource to be the contents of the Dialog.
| |||||||||||
Sets a custom view to be the contents of the alert dialog.
| |||||||||||
Creates an
AlertDialog with the arguments supplied to this
builder and immediately displays the dialog.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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.
context | the parent context |
---|
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_Material_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_Material_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
.
context | the parent context |
---|---|
themeResId | the resource ID of the theme against which to inflate
this dialog, or 0 to use the parent
context 's default alert dialog theme
|
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 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.
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.
adapter | The ListAdapter to supply the list of items |
---|---|
listener | The listener that will be called when an item is clicked. |
Sets whether the dialog is cancelable or not. Default is true.
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.
cursor | The Cursor to supply the list of items |
---|---|
listener | The listener that will be called when an item is clicked. |
labelColumn | The column name on the cursor containing the string to display in the label. |
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()
.
customTitleView | the custom view to use as the title |
---|
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()
.
Set the resource id of the Drawable
to be used in the title.
Takes precedence over values set using setIcon(Drawable)
.
Set an icon as supplied by a theme attribute. e.g.
alertDialogIcon
.
Takes precedence over values set using setIcon(int)
or
setIcon(Drawable)
.
attrId | ID of a theme attribute that points to a drawable resource. |
---|
This method was deprecated
in API level 23.
This flag is only used for pre-Material themes. Instead,
specify the window background using on the alert dialog
theme.
Sets the alert dialog to use the inverse background, regardless of what the contents is.
useInverseBackground | whether to use the inverse background |
---|
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
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.
Set the message to display.
Set the message to display using the given resource id.
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.
items | the text of the items to be displayed in the list. |
---|---|
checkedItems | 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 | 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. |
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.
cursor | the cursor used to provide the items. |
---|---|
isCheckedColumn | 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 | The column name on the cursor containing the string to display in the label. |
listener | 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. |
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.
itemsId | the resource id of an array i.e. R.array.foo |
---|---|
checkedItems | 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 | 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. |
Set a listener to be invoked when the negative button of the dialog is pressed.
text | The text to display in the negative button |
---|---|
listener | The DialogInterface.OnClickListener to use. |
Set a listener to be invoked when the negative button of the dialog is pressed.
textId | The resource id of the text to display in the negative button |
---|---|
listener | The DialogInterface.OnClickListener to use. |
Set a listener to be invoked when the neutral button of the dialog is pressed.
textId | The resource id of the text to display in the neutral button |
---|---|
listener | The DialogInterface.OnClickListener to use. |
Set a listener to be invoked when the neutral button of the dialog is pressed.
text | The text to display in the neutral button |
---|---|
listener | The DialogInterface.OnClickListener to use. |
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
.
Sets the callback that will be called when the dialog is dismissed for any reason.
Sets a listener to be invoked when an item in the list is selected.
listener | the listener to be invoked |
---|
Sets the callback that will be called if a key is dispatched to the dialog.
Set a listener to be invoked when the positive button of the dialog is pressed.
textId | The resource id of the text to display in the positive button |
---|---|
listener | The DialogInterface.OnClickListener to use. |
Set a listener to be invoked when the positive button of the dialog is pressed.
text | The text to display in the positive button |
---|---|
listener | The DialogInterface.OnClickListener to use. |
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.
items | the items to be displayed. |
---|---|
checkedItem | specifies which item is checked. If -1 no items are checked. |
listener | 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. |
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.
adapter | The ListAdapter to supply the list of items |
---|---|
checkedItem | specifies which item is checked. If -1 no items are checked. |
listener | 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. |
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.
itemsId | the resource id of an array i.e. R.array.foo |
---|---|
checkedItem | specifies which item is checked. If -1 no items are checked. |
listener | 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. |
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.
cursor | the cursor to retrieve the items from. |
---|---|
checkedItem | specifies which item is checked. If -1 no items are checked. |
labelColumn | The column name on the cursor containing the string to display in the label. |
listener | 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. |
Set the title displayed in the Dialog
.
Set the title using the given resource id.
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.
layoutResId | Resource ID to be inflated. |
---|
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()
.
view | the view to use as the contents of the alert dialog |
---|
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();