在我的Activity
中我有两个Gallery
项目ExpandableListView
和ExpandableListView
的子项我有GridView
。程序运行完美。我需要的是处理方位变化。我知道,当方向改变时,活动将调用onDestroy
,之后onCreate
。因为我的ExpandableListView
会崩溃,即使用户在他完成方向更改之前已经展开。当Android中发生旋转变化时,ExpandableListView崩溃
我发现了一个很棒的概念来处理在StackOverflow中的旋转变化。这是link。我试图以这种方式实施,但我失败了。
我需要的是在取向改变发生之前采取用户在方向改变之前使用过的相同界面。请指导我。
更新与舱单内容
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".activities.HomeActivity"
android:configChanges="keyboardHidden|orientation|screenLayout" >
<intent-filter>
<action android:name="android.intent.action.MAIN" ></action>
<category android:name="android.intent.category.LAUNCHER" ></category>
</intent-filter>
</activity>
<activity
android:name=".activities.WebViewActivity"
android:configChanges="keyboardHidden|orientation|screenLayout" >
</activity>
</application>
在我的AndroidManifest中,我声明了'android:configChanges =“keyboardHidden | orientation | screenLayout',但它不会帮助我解决问题,是的,我已经阅读了文档并知道必须将前一个实例保存为对象并在onCreate()再次加载时返回,但在我的情况下,我可以声明为Object,因为我填充了两个Gallery项目,一个ExpandableListView和两个GridViews如果我创建一个Object来保存我的最后一个实例我应该保存什么? – AnujAroshA
我不明白。你可以重述一下吗?你是否告诉我添加android:configChanges =“keyboardHidden | orientation | screenLayout”会重新创建你的活动?它会从onCreate重新启动吗? – Blackbelt
是的,它再次从onCreate()方法中调用。我可以看到它注销。在你的评论之后,我已经覆盖了'onConfigurationChanged'方法并调用Log.d()方法。它甚至不在Log中打印。 – AnujAroshA