showDialog deprecated. What#39;s the alternative?(不推荐使用 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 的优势
如何解决?
- http://android-developers.blogspot.in/2012/05/using-dialogfragments.html
更多
- http://developer.android.com/guide/topics/fundamentals/片段.html
- http://developer.android.com/training/basics/fragments/index.html
这篇关于不推荐使用 showDialog.有什么选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:不推荐使用 showDialog.有什么选择?
基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
