语言

Activity.OnCreateDialog 方法

定义

重载

名称 说明
OnCreateDialog(Int32)
已过时.

此方法在 API 级别 15 中已弃用。

OnCreateDialog(Int32, Bundle)
已过时.

用于创建由活动管理的对话框(已保存和还原)的回调。

OnCreateDialog(Int32)

注意

deprecated

此方法在 API 级别 15 中已弃用。

[Android.Runtime.Register("onCreateDialog", "(I)Landroid/app/Dialog;", "GetOnCreateDialog_IHandler")]
[System.Obsolete("deprecated")]
protected virtual Android.App.Dialog? OnCreateDialog(int id);
[<Android.Runtime.Register("onCreateDialog", "(I)Landroid/app/Dialog;", "GetOnCreateDialog_IHandler")>]
[<System.Obsolete("deprecated")>]
abstract member OnCreateDialog : int -> Android.App.Dialog
override this.OnCreateDialog : int -> Android.App.Dialog

参数

id
Int32

int

返回

null 在默认实现中。

特性

注解

此方法在 API 级别 15 中已弃用。 旧 no-arguments version of onCreateDialog(int,Bundle)。

Android 参考。android.app.Activity.onCreateDialog

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

适用于

OnCreateDialog(Int32, Bundle)

注意

deprecated

用于创建由活动管理的对话框(已保存和还原)的回调。

[Android.Runtime.Register("onCreateDialog", "(ILandroid/os/Bundle;)Landroid/app/Dialog;", "GetOnCreateDialog_ILandroid_os_Bundle_Handler")]
[System.Obsolete("deprecated")]
protected virtual Android.App.Dialog? OnCreateDialog(int id, Android.OS.Bundle? args);
[<Android.Runtime.Register("onCreateDialog", "(ILandroid/os/Bundle;)Landroid/app/Dialog;", "GetOnCreateDialog_ILandroid_os_Bundle_Handler")>]
[<System.Obsolete("deprecated")>]
abstract member OnCreateDialog : int * Android.OS.Bundle -> Android.App.Dialog
override this.OnCreateDialog : int * Android.OS.Bundle -> Android.App.Dialog

参数

id
Int32

对话框的 ID。

args
Bundle

提供给 #showDialog(int, Bundle) 的对话框参数。

返回

对话框。 如果返回 null,则不会创建对话框。

特性

注解

此方法在 API 级别 15 中已弃用。 请改用带 FragmentManager 的新 DialogFragment 类;这也可通过 Android 兼容性包在较旧的平台上使用。

用于创建由活动管理的对话框(已保存和还原)的回调。 默认实现通过 onCreateDialog(int) 调用以保持兼容性。 如果你的目标是Build.VERSION_CODES。HONEYCOMB 或更高版本,请考虑改用 DialogFragment。 如果使用 showDialog(int),则活动将在第一次调用此方法,并随后将其挂起。 此方法创建的任何对话框将自动保存和还原,包括是否显示。 如果希望活动管理保存和还原对话框,则应重写此方法并处理传递给 showDialog(int)的任何 ID。 如果希望有机会在显示对话之前准备对话,请重写 onPrepareDialog(int,Dialog,Bundle)。

Android 参考。android.app.Activity.onCreateDialog

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

另请参阅

适用于