showDialog已弃用。有什么办法 [英] showDialog deprecated. What's the alternative?

查看:325
本文介绍了showDialog已弃用。有什么办法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  showDialog(TIME_DIALOG_ID); 

它在本教程,但在Eclipse中表示不推荐使用

解决方案

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


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



在API级别13中不推荐使用此方法。请改用FragmentManager使用新的DialogFragment
类;这也可以通过Android兼容包在旧版
平台上使用。



简单版本的showDialog(int,Bundle)不需要任何
参数。只需调用带有空参数的showDialog(int,Bundle)。


为什么




  • 显示对话窗口,浮动在其活动窗口顶部的片段。该片段包含一个Dialog对象,它根据片段的状态显示适当的对象。对话框的控制(决定何时显示,隐藏,关闭)应该通过这里的API来完成,而不是直接调用对话框。

  • 这是一个很好的讨论
    Android对话框对话框

  • 另一个很好的讨论
    DialogFragment优于AlertDialog



如何解决?





更多




Is there something else that should be called?

showDialog(TIME_DIALOG_ID);

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

解决方案

From 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.

Why

  • A fragment that displays a dialog window, floating on top of its activity's window. This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog.
  • Here is a nice discussion Android DialogFragment vs Dialog
  • Another nice discussion DialogFragment advantages over AlertDialog

How to solve?

More

这篇关于showDialog已弃用。有什么办法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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