IT. Expert System.

Android Reference

AlertDialog.Builder


android.app

Class AlertDialog.Builder

  • Enclosing class:
    AlertDialog


    public static class AlertDialog.Builder
    extends Object
    • Constructor Detail

      • AlertDialog.Builder

        public AlertDialog.Builder(Context context)
        Constructor using a context for this builder and the AlertDialog it creates.
    • Method Detail

      • getContext

        public Context getContext()
        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.
        Returns:
        A Context for built Dialogs.
      • setTitle

        public AlertDialog.Builder setTitle(int titleId)
        Set the title using the given resource id.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setCustomTitle

        public AlertDialog.Builder setCustomTitle(View customTitleView)
        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.
        Parameters:
        customTitleView - The custom view to use as the title.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setMessage

        public AlertDialog.Builder setMessage(int messageId)
        Set the message to display using the given resource id.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setMessage

        public AlertDialog.Builder setMessage(CharSequence message)
        Set the message to display.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setIcon

        public AlertDialog.Builder setIcon(int iconId)
        Set the resource id of the Drawable to be used in the title.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setIcon

        public AlertDialog.Builder setIcon(Drawable icon)
        Set the Drawable to be used in the title.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setIconAttribute

        public AlertDialog.Builder setIconAttribute(int attrId)
        Set an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon
        Parameters:
        attrId - ID of a theme attribute that points to a drawable resource.
      • setPositiveButton

        public AlertDialog.Builder setPositiveButton(int textId,
                                            DialogInterface.OnClickListener listener)
        Set a listener to be invoked when the positive button of the dialog is pressed.
        Parameters:
        textId - The resource id of the text to display in the positive button
        listener - The DialogInterface.OnClickListener to use.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setPositiveButton

        public AlertDialog.Builder setPositiveButton(CharSequence text,
                                            DialogInterface.OnClickListener listener)
        Set a listener to be invoked when the positive button of the dialog is pressed.
        Parameters:
        text - The text to display in the positive button
        listener - The DialogInterface.OnClickListener to use.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setNegativeButton

        public AlertDialog.Builder setNegativeButton(int textId,
                                            DialogInterface.OnClickListener listener)
        Set a listener to be invoked when the negative button of the dialog is pressed.
        Parameters:
        textId - The resource id of the text to display in the negative button
        listener - The DialogInterface.OnClickListener to use.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setNegativeButton

        public AlertDialog.Builder setNegativeButton(CharSequence text,
                                            DialogInterface.OnClickListener listener)
        Set a listener to be invoked when the negative button of the dialog is pressed.
        Parameters:
        text - The text to display in the negative button
        listener - The DialogInterface.OnClickListener to use.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setNeutralButton

        public AlertDialog.Builder setNeutralButton(int textId,
                                           DialogInterface.OnClickListener listener)
        Set a listener to be invoked when the neutral button of the dialog is pressed.
        Parameters:
        textId - The resource id of the text to display in the neutral button
        listener - The DialogInterface.OnClickListener to use.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setNeutralButton

        public AlertDialog.Builder setNeutralButton(CharSequence text,
                                           DialogInterface.OnClickListener listener)
        Set a listener to be invoked when the neutral button of the dialog is pressed.
        Parameters:
        text - The text to display in the neutral button
        listener - The DialogInterface.OnClickListener to use.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setCancelable

        public AlertDialog.Builder setCancelable(boolean cancelable)
        Sets whether the dialog is cancelable or not. Default is true.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setOnDismissListener

        public AlertDialog.Builder setOnDismissListener(DialogInterface.OnDismissListener onDismissListener)
        Sets the callback that will be called when the dialog is dismissed for any reason.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setOnKeyListener

        public AlertDialog.Builder setOnKeyListener(DialogInterface.OnKeyListener onKeyListener)
        Sets the callback that will be called if a key is dispatched to the dialog.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setItems

        public 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. This should be an array type i.e. R.array.foo
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setItems

        public 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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setAdapter

        public 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.
        Parameters:
        adapter - The ListAdapter to supply the list of items
        listener - The listener that will be called when an item is clicked.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setCursor

        public 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.
        Parameters:
        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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setMultiChoiceItems

        public 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. 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 - 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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setMultiChoiceItems

        public 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. 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 - 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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setMultiChoiceItems

        public 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. 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:
        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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setSingleChoiceItems

        public AlertDialog.Builder setSingleChoiceItems(int itemsId,
                                               int checkedItem,
                                               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. 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.
        Parameters:
        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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setSingleChoiceItems

        public AlertDialog.Builder setSingleChoiceItems(Cursor cursor,
                                               int checkedItem,
                                               String labelColumn,
                                               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. 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.
        Parameters:
        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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setSingleChoiceItems

        public AlertDialog.Builder setSingleChoiceItems(CharSequence[] items,
                                               int checkedItem,
                                               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. 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.
        Parameters:
        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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setSingleChoiceItems

        public AlertDialog.Builder setSingleChoiceItems(ListAdapter adapter,
                                               int checkedItem,
                                               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. 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.
        Parameters:
        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.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setView

        public AlertDialog.Builder setView(View view)
        Set a custom view to be the contents of the Dialog. If the supplied view is an instance of a ListView the light background will be used.
        Parameters:
        view - The view to use as the contents of the Dialog.
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setView

        public AlertDialog.Builder setView(View view,
                                  int viewSpacingLeft,
                                  int viewSpacingTop,
                                  int viewSpacingRight,
                                  int viewSpacingBottom)
        Set a custom view to be the contents of the Dialog, specifying the spacing to appear around that view. If the supplied view is an instance of a ListView the light background will be used.
        Parameters:
        view - The view to use as the contents of the Dialog.
        viewSpacingLeft - Spacing between the left edge of the view and the dialog frame
        viewSpacingTop - Spacing between the top edge of the view and the dialog frame
        viewSpacingRight - Spacing between the right edge of the view and the dialog frame
        viewSpacingBottom - Spacing between the bottom edge of the view and the dialog frame
        Returns:
        This Builder object to allow for chaining of calls to set methods This is currently hidden because it seems like people should just be able to put padding around the view.
      • setInverseBackgroundForced

        public AlertDialog.Builder setInverseBackgroundForced(boolean useInverseBackground)
        Sets the Dialog to use the inverse background, regardless of what the contents is.
        Parameters:
        useInverseBackground - Whether to use the inverse background
        Returns:
        This Builder object to allow for chaining of calls to set methods
      • setRecycleOnMeasureEnabled

        public AlertDialog.Builder setRecycleOnMeasureEnabled(boolean enabled)
      • create

        public AlertDialog create()
        Creates a AlertDialog with the arguments supplied to this builder. It does not Dialog.show() the dialog. This allows the user to do any extra processing before displaying the dialog. Use show() if you don't have any other processing to do and want this to be created and displayed.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 3192 / . Delta: 0.04739 с