如何应对方向变化与ProgressDialog的表现? [英] How to deal with orientation change with a ProgressDialog showing?

查看:132
本文介绍了如何应对方向变化与ProgressDialog的表现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显示一个 ProgressDialog 中的AsyncTask对象的在preExecute 方法和取消ProgressDialog在 onPostExecute 方法。在 doInBackground 方法,我做了用户注册的HTTP请求。我希望允许屏幕方向的变化。当我改变方向,而 doInBackground 的方法仍然在运行,我得到各种有趣的错误像抛出:IllegalArgumentException:查看未连接到窗口管理器和RegisterScreen渗漏窗口......

I am showing a ProgressDialog in the onPreExecute method of an AsyncTask object and canceling the ProgressDialog in the onPostExecute method. In the doInBackground method I am making an HTTP request for user registration. I wish to allow screen orientation changes. When I change the orientation while the doInBackground method is still running, i get all sorts of fun errors like 'IllegalArgumentException: View not attached to window manager' and 'RegisterScreen has leaked window...'

我怎样才能正确地继续的方向改变后,显示 ProgressDialog ?或者,也许,我怎么能禁用用户的请求后,方向更改提交他们的注册?

How can I properly continue to show the ProgressDialog after an orientation change? Or maybe, how can I disable orientation change after the user requests to submit their registration?

推荐答案

尝试添加该属性安卓configChanges =定向活动的Andr​​oidManifest.xml 文件中的元素。

Try adding this attribute android:configChanges="orientation" to your Activity element in the AndroidManifest.xml file.

这篇关于如何应对方向变化与ProgressDialog的表现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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