using onSaveInstanceState(Bundle ..) and onRestoreInstanceState(Bundle ..)
was really good and work, but it is working when click Turn off button on Emulator.
Now, i want to save state and restore the saved data when below button used:
我认为可以使用 OnPause() 或 oOnStop(),如果我是对的,如何使用它,
向我展示保存一个布尔变量并恢复它的 Java 源代码就足够了,
Thanks.
我会用onPause()
, as onStop()
不保证被调用。请参阅应用基础 http://developer.android.com/guide/topics/fundamentals.html有关生命周期的详细信息。
要保存和恢复布尔值,我会使用SharedPreferences
。上有一个代码示例数据存储页面 http://developer.android.com/guide/topics/data/data-storage.html#pref这展示了如何保存和恢复布尔值。他们使用onCreate()
and onStop()
,但我会用onResume()
and onPause()
,出于我已经提到的原因。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)