Android 抽屉布局、主要活动和方向更改
我的主要活动布局xml如下所示:Android 抽屉布局、主要活动和方向更改,android,android-fragments,orientation,Android,Android Fragments,Orientation,我的主要活动布局xml如下所示: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> &
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
FrameLayout包含不同的片段,一切正常。每个片段包含setRetainInstance(true)代码>但由于保存所有内容的主活动是一个活动,它没有,结果是当方向发生变化时,会重新创建主活动,导致所有应用程序重新启动,因此我完全不想保留片段
再解释一下:当应用程序打开时,MainActivity调用片段A。用户打开片段B并重新定向屏幕。重新创建主活动,导致片段A再次显示。savedInstanceState无法帮助我保存显示的最后一个片段,因为它只会再次强制重新加载片段B,尽管我希望它保留其实例
你知道我该怎么解决这个问题吗
谢谢什么都没有?没有人遇到过这个问题?