【问题标题】:How can I save state between orientations?如何在方向之间保存状态?
【发布时间】:2011-04-08 02:48:57
【问题描述】:

在上一个问题中,我询问了如何为纵向和横向显示两种不同的布局:

Problem switching to landscape orientation

现在我想知道如何在应用程序进入另一个方向之前保存它的状态?每当方向改变时,我似乎都会丢失这些数据。

【问题讨论】:

    标签: java android configuration orientation


    【解决方案1】:

    这种问题一直是answered before

    但也有其他方法未在上一个答案中列出。例如使用onRestoreInstanceState() 方法,如explained here。这种方法是在配置更改之间存储状态的推荐方法,直到最近才被记录下来。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-30
      • 1970-01-01
      • 2014-06-30
      • 2015-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多