不推荐使用 showDialog.有什么选择? [英] showDialog deprecated. What's the alternative?

查看:26
本文介绍了不推荐使用 showDialog.有什么选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有什么需要调用的吗?

Is there something else that should be called?

showDialog(TIME_DIALOG_ID);

它在 本教程中,但在 deprecated日食.

It's in this tutorial but says deprecated in Eclipse.

推荐答案

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

public final void showDialog (int id) 在 API 级别 1 中添加

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

此方法在 API 级别 13 中已弃用.使用新的 DialogFragment改为使用 FragmentManager 类;这也适用于较旧的平台通过 Android 兼容包.

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.

showDialog(int, Bundle) 的简单版本,不需要任何论据.只需使用 null 参数调用 showDialog(int, Bundle).

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

为什么

  • 显示对话窗口的片段,浮动在其活动窗口的顶部.该片段包含一个 Dialog 对象,它会根据片段的状态适当地显示该对象.对话框的控制(决定何时显示、隐藏、关闭)应通过此处的 API 完成,而不是直接调用对话框.
  • 这是一个很好的讨论Android DialogFragment vs Dialog
  • 另一个很好的讨论DialogFragment 相对于 AlertDialog 的优势

如何解决?

更多

这篇关于不推荐使用 showDialog.有什么选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆