Share via


AlertDialog Constructors

Definition

Overloads

AlertDialog(Context)

Creates an alert dialog that uses the default alert dialog theme.

AlertDialog(Context, Int32)

Creates an alert dialog that uses an explicit theme resource.

AlertDialog(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

AlertDialog(Context, Boolean, IDialogInterfaceOnCancelListener)

Creates an alert dialog that uses the default alert dialog theme.

AlertDialog(Context, Boolean, EventHandler)

AlertDialog(Context)

Creates an alert dialog that uses the default alert dialog theme.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")]
protected AlertDialog (Android.Content.Context? context);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")>]
new Android.App.AlertDialog : Android.Content.Context -> Android.App.AlertDialog

Parameters

context
Context

the parent context

Attributes

Remarks

Creates 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.

Java documentation for android.app.AlertDialog.AlertDialog(android.content.Context).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

AlertDialog(Context, Int32)

Creates an alert dialog that uses an explicit theme resource.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;I)V", "")]
protected AlertDialog (Android.Content.Context? context, int themeResId);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;I)V", "")>]
new Android.App.AlertDialog : Android.Content.Context * int -> Android.App.AlertDialog

Parameters

context
Context

the parent context

themeResId
Int32

the resource ID of the theme against which to inflate this dialog, or 0 to use the parent context's default alert dialog theme

Attributes

Remarks

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

Java documentation for android.app.AlertDialog.AlertDialog(android.content.Context, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

AlertDialog(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected AlertDialog (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.App.AlertDialog : nativeint * Android.Runtime.JniHandleOwnership -> Android.App.AlertDialog

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

AlertDialog(Context, Boolean, IDialogInterfaceOnCancelListener)

Creates an alert dialog that uses the default alert dialog theme.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;ZLandroid/content/DialogInterface$OnCancelListener;)V", "")]
protected AlertDialog (Android.Content.Context? context, bool cancelable, Android.Content.IDialogInterfaceOnCancelListener? cancelListener);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;ZLandroid/content/DialogInterface$OnCancelListener;)V", "")>]
new Android.App.AlertDialog : Android.Content.Context * bool * Android.Content.IDialogInterfaceOnCancelListener -> Android.App.AlertDialog

Parameters

context
Context

the parent context

cancelable
Boolean
Attributes

Remarks

Java documentation for android.app.AlertDialog.AlertDialog(android.content.Context).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

AlertDialog(Context, Boolean, EventHandler)

protected AlertDialog (Android.Content.Context context, bool cancelable, EventHandler cancelHandler);
new Android.App.AlertDialog : Android.Content.Context * bool * EventHandler -> Android.App.AlertDialog

Parameters

context
Context
cancelable
Boolean
cancelHandler
EventHandler

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to