Android避免对话框在设备旋转后关闭的最佳方式 [英] Android Best way of avoid Dialogs to dismiss after a device rotation

查看:172
本文介绍了Android避免对话框在设备旋转后关闭的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个论坛上搜索很长时间之后,我发现很多答案,人们提出使用解决方案避免对话框在轮播后关闭,就像:

  android:configChanges =keyboardHidden | orientation

或覆盖以下方法,这似乎是最推荐的:

  protected对话框onCreateDialog(int id)

但是,在浏览Android参考文档后,我可以注意到这些Dialog方法已被弃用。



所以,显而易见的问题是:



今天,在设备旋转后避免对话框关闭的最佳方法是什么? >



提前感谢

解决方案

来自新Fragments API的href =http://developer.android.com/reference/android/app/DialogFragment.html> DialogFragment 。要在3.0以上的平台上使用它,请使用兼容性包


After a long search around this forum, I found a lot of answers where people propose using solutions for avoiding dialogs to dismiss after rotation, just like:

android:configChanges="keyboardHidden|orientation"

Or override the following method, which appeared to be the most recommended:

protected Dialog onCreateDialog(int id)

But, after look around the Android Reference Documentation, I could notice that these Dialog methods are being deprecated.

So, the obvious question is:

Today, what is the best way of avoid Dialogs to dismiss after a device rotation?

Thanks in advance.

解决方案

You should now use DialogFragment from new Fragments API. To use it on the platform lower, than 3.0, use compatibility package.

这篇关于Android避免对话框在设备旋转后关闭的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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