语言

AlertDialog 构造函数

定义

重载

名称 说明
AlertDialog(Context)

创建使用默认警报对话主题的警报对话框。

AlertDialog(Context, Int32)

创建使用显式主题资源的警报对话框。

AlertDialog(IntPtr, JniHandleOwnership)

初始化现有 Java Native Interface 对象的托管表示形式。

AlertDialog(Context, Boolean, IDialogInterfaceOnCancelListener)

创建使用默认警报对话主题和自定义取消侦听器的警报对话框。

AlertDialog(Context, Boolean, EventHandler)

使用托管取消处理程序初始化警报对话框。

AlertDialog(Context)

创建使用默认警报对话主题的警报对话框。

[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

参数

context
Context

父上下文

特性

注解

创建使用默认警报对话主题的警报对话框。 默认警报对话框主题由父上下文主题中的 R.attr.alertDialogTheme 定义。

Android 参考。android.app.AlertDialog.AlertDialog

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

AlertDialog(Context, Int32)

创建使用显式主题资源的警报对话框。

[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

参数

context
Context

父上下文

themeResId
Int32

要对其放大此对话的主题的资源 ID,或使用 0 父 context级的默认警报对话主题

特性

注解

创建使用显式主题资源的警报对话框。 指定的主题资源 (themeResId) 将应用于父上下文的主题之上。 它可以指定为包含完全填充的主题(如 R.style.Theme_Material_Dialog)的样式资源,以替换父上下文主题中的所有属性,包括主要颜色和主题色。 若要保留主要颜色和主题色等属性,可以改为将 themeResId 指定为覆盖主题,例如R.style.ThemeOverlay_Material_Dialog。 这将仅替代将警报窗口设置为对话框样式所需的窗口属性。 或者,可将 themeResId 指定为 0,以使用 R.attr.alertDialogTheme 的父上下文解析值。

Android 参考。android.app.AlertDialog.AlertDialog

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

AlertDialog(IntPtr, JniHandleOwnership)

初始化现有 Java Native Interface 对象的托管表示形式。

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

参数

javaReference
IntPtr

nativeint

Java Native Interface 对象引用。

transfer
JniHandleOwnership

要应用于 Java Native Interface 对象引用的所有权转让。

注解

当为现有Java对象创建托管对等时,此构造函数由 Android 绑定运行时的 .NET 调用。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

AlertDialog(Context, Boolean, IDialogInterfaceOnCancelListener)

创建使用默认警报对话主题和自定义取消侦听器的警报对话框。

[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

参数

context
Context

上下文:父上下文

cancelable
Boolean

boolean

cancelListener
IDialogInterfaceOnCancelListener

DialogInterface.OnCancelListener

特性

注解

创建使用默认警报对话主题和自定义取消侦听器的警报对话框。 这在功能上与:

AlertDialog dialog = new AlertDialog(context);
dialog.setCancelable(cancelable);
dialog.setOnCancelListener(cancelListener);

默认警报对话框主题由父上下文主题中的 R.attr.alertDialogTheme 定义。

Android 参考。android.app.AlertDialog.AlertDialog

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

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

参数

context
Context

转发到平台警报对话构造函数的父上下文。

cancelable
Boolean

对话框是否标记为可取消。

cancelHandler
EventHandler

要包装为取消侦听器的托管处理程序。

注解

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于