Android开发:屏幕方向的问题 [英] Android dev: screen orientation problems

查看:143
本文介绍了Android开发:屏幕方向的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定我有屏幕方向真正的麻烦。我的应用程序有一个倒数计时器在它与其它变量。 而每次屏幕会从横向到纵向模式我所有的变量得到重置为默认值,倒数计时器被canceld和复位! 正所谓onCreate方法每次画面变化orintation? 有没有办法解决这个问题?

ok i am having real troubles with screen orientation. My application has a countdown timer in it along with other variables. And everytime the screen goes from landscape to portrait mode all my variables get reset to their default value, and the countdown timer gets canceld and reset !!! Is the onCreate method called everytime the screen changes orintation ? is there a solution to this problem ?

推荐答案

是的,的onCreate被称为每次旋转屏幕的时间。你必须保存您的应用程序的状态,通过覆盖的onSaveInstanceState 的方法,并在的onCreate 的恢复状态。在这两种方法,你必须捆绑对象来存储/检索状态。

Yes, onCreate is called every time you rotate the screen. You have to save state of your app by overriding onSaveInstanceState method and the restore the state at onCreate. At both methods you have Bundle object to store/retrieve state.

阅读 http://developer.android.com /intl/zh-TW/guide/topics/fundamentals.html#actlife 了解活动的生命周期。

Read http://developer.android.com/intl/zh-TW/guide/topics/fundamentals.html#actlife for understanding activity life cycle.

这篇关于Android开发:屏幕方向的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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