English | Site Directory

Android - An Open Handset Alliance Project

android.app
public static class

android.app.AlertDialog.Builder

java.lang.Object
android.app.AlertDialog.Builder

Summary

Public Constructors

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

Public Methods

        AlertDialog  create()
Creates a AlertDialog with the arguments supplied to this builder.
        Builder  setCancelable(boolean cancelable)
Sets whether the dialog is cancelable or not default is true.
        Builder  setIcon(Drawable icon)
Set the Drawable to be used in the title.
        Builder  setIcon(int iconId)
Set the resource id of the Drawable to be used in the title.
        Builder  setItems(int itemsId, 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.
        Builder  setMessage(int messageId)
Set the message to display using the given resource id.
        Builder  setMessage(CharSequence message)
Set the message to display.
        Builder  setNegativeButton(CharSequence text, OnClickListener listener)
Set a listener to be invoked when the negative button of the dialog is pressed.
        Builder  setNegativeButton(int textId, OnClickListener listener)
Set a listener to be invoked when the negative button of the dialog is pressed.
        Builder  setNeutralButton(int textId, OnClickListener listener)
Set a listener to be invoked when the neutral button of the dialog is pressed.
        Builder  setNeutralButton(CharSequence text, OnClickListener listener)
Set a listener to be invoked when the neutral button of the dialog is pressed.
        Builder  setOnCancelListener(OnCancelListener onCancelListener)
Sets the callback that will be called if the dialog is canceled.
        Builder  setPositiveButton(CharSequence text, OnClickListener listener)
Set a listener to be invoked when the positive button of the dialog is pressed.
        Builder  setPositiveButton(int textId, OnClickListener listener)
Set a listener to be invoked when the positive button of the dialog is pressed.
        Builder  setTitle(CharSequence title)
Set the title displayed in the Dialog.
        Builder  setTitle(int titleId)
Set the title using the given resource id.
        Builder  setView(View view)
        AlertDialog  show()
Creates a AlertDialog with the arguments supplied to this builder and show()'s the dialog.
Methods inherited from class java.lang.Object

Details

Public Constructors

public AlertDialog.Builder(Context context)

Constructor using a context for this builder and the AlertDialog it creates.

Public Methods

public AlertDialog create()

Creates a AlertDialog with the arguments supplied to this builder. It does not 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.

public Builder setCancelable(boolean cancelable)

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

public Builder setIcon(Drawable icon)

Set the Drawable to be used in the title.

public Builder setIcon(int iconId)

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

public Builder setItems(int itemsId, 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

public Builder setMessage(int messageId)

Set the message to display using the given resource id.

public Builder setMessage(CharSequence message)

Set the message to display.

public Builder setNegativeButton(CharSequence text, 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.

public Builder setNegativeButton(int textId, 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.

public Builder setNeutralButton(int textId, 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.

public Builder setNeutralButton(CharSequence text, 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.

public Builder setOnCancelListener(OnCancelListener onCancelListener)

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

public Builder setPositiveButton(CharSequence text, 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.

public Builder setPositiveButton(int textId, 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.

public Builder setTitle(CharSequence title)

Set the title displayed in the Dialog.

public Builder setTitle(int titleId)

Set the title using the given resource id.

public Builder setView(View view)

public AlertDialog show()

Creates a AlertDialog with the arguments supplied to this builder and show()'s the dialog.
Build m5-rc15g - 14 May 2008 12:50