O Google tem o compromisso de promover a igualdade racial para as comunidades negras. Saiba como.

Builder

open class Builder
kotlin.Any
   ↳ androidx.appcompat.app.AlertDialog.Builder

Summary

Public constructors
<init>(@NonNull context: Context)

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

<init>(@NonNull context: Context, @StyleRes themeResId: Int)

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

Public methods
open AlertDialog

Creates an AlertDialog with the arguments supplied to this builder.

open Context

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

open AlertDialog.Builder!
setAdapter(adapter: ListAdapter!, listener: OnClickListener!)

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.

open AlertDialog.Builder!
setCancelable(cancelable: Boolean)

Sets whether the dialog is cancelable or not.

open AlertDialog.Builder!
setCursor(cursor: Cursor!, listener: OnClickListener!, labelColumn: String!)

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.

open AlertDialog.Builder!
setCustomTitle(@Nullable customTitleView: View?)

Set the title using the custom view customTitleView.

open AlertDialog.Builder!
setIcon(@DrawableRes iconId: Int)

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

open AlertDialog.Builder!
setIcon(@Nullable icon: Drawable?)

Set the Drawable to be used in the title.

open AlertDialog.Builder!
setIconAttribute(@AttrRes attrId: Int)

Set an icon as supplied by a theme attribute.

open AlertDialog.Builder!
setInverseBackgroundForced(useInverseBackground: Boolean)

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

open AlertDialog.Builder!
setItems(@ArrayRes itemsId: Int, listener: OnClickListener!)

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.

open AlertDialog.Builder!
setItems(items: Array<CharSequence!>!, listener: OnClickListener!)

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.

open AlertDialog.Builder!
setMessage(@StringRes messageId: Int)

Set the message to display using the given resource id.

open AlertDialog.Builder!
setMessage(@Nullable message: CharSequence?)

Set the message to display.

open AlertDialog.Builder!
setMultiChoiceItems(@ArrayRes itemsId: Int, checkedItems: BooleanArray!, listener: OnMultiChoiceClickListener!)

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.

open AlertDialog.Builder!

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.

open AlertDialog.Builder!
setMultiChoiceItems(cursor: Cursor!, isCheckedColumn: String!, labelColumn: String!, listener: OnMultiChoiceClickListener!)

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.

open AlertDialog.Builder!
setNegativeButton(@StringRes textId: Int, listener: OnClickListener!)

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

open AlertDialog.Builder!

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

open AlertDialog.Builder!

Set an icon to be displayed for the negative button.

open AlertDialog.Builder!
setNeutralButton(@StringRes textId: Int, listener: OnClickListener!)

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

open AlertDialog.Builder!

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

open AlertDialog.Builder!

Set an icon to be displayed for the neutral button.

open AlertDialog.Builder!

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

open AlertDialog.Builder!

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

open AlertDialog.Builder!

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

open AlertDialog.Builder!

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

open AlertDialog.Builder!
setPositiveButton(@StringRes textId: Int, listener: OnClickListener!)

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

open AlertDialog.Builder!

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

open AlertDialog.Builder!

Set an icon to be displayed for the positive button.

open AlertDialog.Builder!
setSingleChoiceItems(@ArrayRes itemsId: Int, checkedItem: Int, listener: OnClickListener!)

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.

open AlertDialog.Builder!
setSingleChoiceItems(cursor: Cursor!, checkedItem: Int, labelColumn: String!, listener: OnClickListener!)

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.

open AlertDialog.Builder!
setSingleChoiceItems(items: Array<CharSequence!>!, checkedItem: Int, listener: OnClickListener!)

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.

open AlertDialog.Builder!
setSingleChoiceItems(adapter: ListAdapter!, checkedItem: Int, listener: OnClickListener!)

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.

open AlertDialog.Builder!
setTitle(@StringRes titleId: Int)

Set the title using the given resource id.

open AlertDialog.Builder!
setTitle(@Nullable title: CharSequence?)

Set the title displayed in the Dialog.

open AlertDialog.Builder!
setView(layoutResId: Int)

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

open AlertDialog.Builder!
setView(view: View!)

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

open AlertDialog!

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

Public constructors

<init>

Builder(@NonNull context: Context)

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

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

Parameters
context Context: the parent context

<init>

Builder(
    @NonNull context: Context,
    @StyleRes themeResId: Int)

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 R.style#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 R.style#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 android.R.attr#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

@NonNull open fun create(): AlertDialog

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.

getContext

@NonNull open fun getContext(): Context

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.

Return
Context A Context for built Dialogs.

setAdapter

open fun setAdapter(
    adapter: ListAdapter!,
    listener: OnClickListener!
): AlertDialog.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.

Parameters
adapter ListAdapter!: The ListAdapter to supply the list of items
listener OnClickListener!: The listener that will be called when an item is clicked.
Return
AlertDialog.Builder! This Builder object to allow for chaining of calls to set methods

setCancelable

open fun setCancelable(cancelable: Boolean): AlertDialog.Builder!

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

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

setCursor

open fun setCursor(
    cursor: Cursor!,
    listener: OnClickListener!,
    labelColumn: String!
): AlertDialog.Builder!

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 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.
Return
AlertDialog.Builder! This Builder object to allow for chaining of calls to set methods

setCustomTitle

open fun setCustomTitle(@Nullable customTitleView: View?): AlertDialog.Builder!

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
Return
AlertDialog.Builder! this Builder object to allow for chaining of calls to set methods

setIcon

open fun setIcon(@DrawableRes iconId: Int): AlertDialog.Builder!

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

Takes precedence over values set using setIcon(Drawable).

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

setIcon

open fun setIcon(@Nullable icon: Drawable?): AlertDialog.Builder!

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

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

setIconAttribute

open fun setIconAttribute(@AttrRes attrId: Int): AlertDialog.Builder!

Set an icon as supplied by a theme attribute. e.g. android.R.attr#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.

setInverseBackgroundForced

open fun setInverseBackgroundForced(useInverseBackground: Boolean): AlertDialog.Builder!

Deprecated: 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
Return
AlertDialog.Builder! This Builder object to allow for chaining of calls to set methods

setItems

open fun setItems(
    @ArrayRes itemsId: Int,
    listener: OnClickListener!
): AlertDialog.Builder!

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

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

setItems

open fun setItems(
    items: Array<CharSequence!>!,
    listener: OnClickListener!
): AlertDialog.Builder!

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.

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

setMessage

open fun setMessage(@StringRes messageId: Int): AlertDialog.Builder!

Set the message to display using the given resource id.

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

setMessage

open fun setMessage(@Nullable message: CharSequence?): AlertDialog.Builder!

Set the message to display.

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

setMultiChoiceItems

open fun setMultiChoiceItems(
    @ArrayRes itemsId: Int,
    checkedItems: BooleanArray!,
    listener: OnMultiChoiceClickListener!
): AlertDialog.Builder!

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 BooleanArray!: 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 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.
Return
AlertDialog.Builder! This Builder object to allow for chaining of calls to set methods

setMultiChoiceItems

open fun setMultiChoiceItems(
    items: Array<CharSequence!>!,
    checkedItems: BooleanArray!,
    listener: OnMultiChoiceClickListener!
): AlertDialog.Builder!

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 Array<CharSequence!>!: the text of the items to be displayed in the list.
checkedItems BooleanArray!: 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 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.
Return
AlertDialog.Builder! This Builder object to allow for chaining of calls to set methods

setMultiChoiceItems

open fun setMultiChoiceItems(
    cursor: Cursor!,
    isCheckedColumn: String!,