android – showDialog已弃用。有什么替代方法?

还有别的东西应该叫吗?

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.

为什么

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

如何解决?

> http://android-developers.blogspot.in/2012/05/using-dialogfragments.html

更多

> http://developer.android.com/guide/topics/fundamentals/fragments.html
> http://developer.android.com/training/basics/fragments/index.html

http://stackoverflow.com/questions/10285047/showdialog-deprecated-whats-the-alternative

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:android – showDialog已弃用。有什么替代方法?