Android Guides | Samples

Android.App.AlertDialog Class

A subclass of Dialog that can display one, two or three buttons.

See Also: AlertDialog

Syntax

[Android.Runtime.Register("android/app/AlertDialog", DoNotGenerateAcw=true)]
public class AlertDialog : Dialog, IDisposable

Remarks

A subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method. If you want to display a more complex view, look up the FrameLayout called "custom" and add your view to it:

java Example

 FrameLayout fl = (FrameLayout) findViewById(android.R.id.custom);
 fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

The AlertDialog class takes care of automatically setting Android.Views.WindowManagerLayoutParams.FLAG_ALT_FOCUSABLE_IM for you based on whether any views in the dialog return true from View.OnCheckIsTextEditor. Generally you want this set for a Dialog without text editors, so that it will be placed on top of the current input method UI. You can modify this behavior by forcing the flag to your desired mode after calling AlertDialog.onCreate(android.os.Bundle).

Developer Guides

For more information about creating dialogs, read the Dialogs developer guide.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.App.AlertDialog are listed below.

See Also: Dialog

Protected Constructors

Creates an alert dialog that uses the default alert dialog theme.
Creates an alert dialog that uses an explicit theme resource.
A constructor used when creating managed representations of JNI objects; called by the runtime.
Creates an alert dialog that uses the default alert dialog theme and a custom cancel listener.

Public Fields

const
ThemeDeviceDefaultDarkInt32 (4). Special theme constant for stem.Int32): use the device's default alert theme with a dark background.
const
ThemeDeviceDefaultLightInt32 (5). Special theme constant for stem.Int32): use the device's default alert theme with a light background.
const
ThemeHoloDarkInt32 (2). Special theme constant for stem.Int32): use the holographic alert theme with a dark background.
const
ThemeHoloLightInt32 (3). Special theme constant for stem.Int32): use the holographic alert theme with a light background.
const
ThemeTraditionalInt32 (1). Special theme constant for stem.Int32): use the traditional (pre-Holo) alert dialog theme.

Public Properties

[read-only]
ListViewListView. Gets the list view used in the dialog.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

GetButton(Int32) : Button
Gets one of the buttons used in the dialog.
SetButton(ICharSequence, IDialogInterfaceOnClickListener)
Set a listener to be invoked when button 1 of the dialog is pressed.
SetButton(ICharSequence, Message)
SetButton(ICharSequence, EventHandler<Android.Content.DialogClickEventArgs>)
SetButton(String, IDialogInterfaceOnClickListener)
SetButton(String, Message)
SetButton(String, EventHandler<Android.Content.DialogClickEventArgs>)
SetButton(Int32, ICharSequence, IDialogInterfaceOnClickListener)
Set a listener to be invoked when the positive button of the dialog is pressed.
SetButton(Int32, ICharSequence, Message)
Set a message to be sent when a button is pressed.
SetButton(Int32, ICharSequence, EventHandler<Android.Content.DialogClickEventArgs>)
SetButton(Int32, String, IDialogInterfaceOnClickListener)
SetButton(Int32, String, Message)
SetButton(Int32, String, EventHandler<Android.Content.DialogClickEventArgs>)
SetButton2(ICharSequence, IDialogInterfaceOnClickListener)
Set a listener to be invoked when button 2 of the dialog is pressed.
SetButton2(ICharSequence, Message)
SetButton2(ICharSequence, EventHandler<Android.Content.DialogClickEventArgs>)
SetButton2(String, IDialogInterfaceOnClickListener)
SetButton2(String, Message)
SetButton2(String, EventHandler<Android.Content.DialogClickEventArgs>)
SetButton3(ICharSequence, IDialogInterfaceOnClickListener)
Set a listener to be invoked when button 3 of the dialog is pressed.
SetButton3(ICharSequence, Message)
SetButton3(ICharSequence, EventHandler<Android.Content.DialogClickEventArgs>)
SetButton3(String, IDialogInterfaceOnClickListener)
SetButton3(String, Message)
SetButton3(String, EventHandler<Android.Content.DialogClickEventArgs>)
SetCustomTitle(View)
SetIcon(Drawable)
SetIcon(Int32)
Set resId to 0 if you don't want an icon.
SetIconAttribute(Int32)
Set an icon as supplied by a theme attribute. e.g. android.
SetInverseBackgroundForced(Boolean)
SetMessage(ICharSequence)
SetMessage(String)
SetView(View)
Set the view to display in that dialog.
SetView(View, Int32, Int32, Int32, Int32)
Set the view to display in that dialog, specifying the spacing to appear around that view.