android - 不推荐使用 showDialog。有什么选择?

标签 android dialog

还有什么需要调用的吗?

showDialog(TIME_DIALOG_ID);

this tutorial但在 Eclipse 中说 已弃用

最佳答案

来自 http://developer.android.com/reference/android/app/Activity.html

public final void showDialog (int id) Added in API level 1

This method was deprecated in API level 13. Use the new DialogFragment class with FragmentManager instead; this is also available on older platforms through the Android compatibility package.

Simple version of showDialog(int, Bundle) that does not take any arguments. Simply calls showDialog(int, Bundle) with null arguments.

为什么

  • 显示对话窗口的 fragment , float 在其 Activity 窗口的顶部。该 fragment 包含一个 Dialog 对象,它会根据 fragment 的状态适本地显示该对象。对话框的控制(决定何时显示、隐藏、关闭)应通过此处的 API 完成,而不是直接调用对话框。
  • 这是一个很好的讨论 Android DialogFragment vs Dialog
  • 另一个很好的讨论 DialogFragment advantages over AlertDialog

如何解决?

更多

关于android - 不推荐使用 showDialog。有什么选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10285047/

相关文章:

android捕获的图像是纵向的

java - 绑定(bind)项目内部类的可访问性不一致,但无法获得正确的转换语法

android - ConstraintLayout 在预览时显示错误的布局,即使在蓝图上没问题

java - 如何等待多个 Volley 请求完成?

php - 在模态对话框中打开链接(如 Chrome 网上应用店)

.net - 如何在WPF中制作模式对话框?

java - 将 30 分钟添加到 java 中的当前时间

c# - 为什么异常不会在 WPF 对话框关闭事件处理程序之外冒泡?

javascript - CKEditor 调用 openDialog 我淡出但没有对话框

android - 将 onClick 添加到对话框布局中没有类的按钮