Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 抽屉布局、主要活动和方向更改_Android_Android Fragments_Orientation - Fatal编程技术网

Android 抽屉布局、主要活动和方向更改

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"> &

我的主要活动布局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">

    <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,尽管我希望它保留其实例

你知道我该怎么解决这个问题吗


谢谢

什么都没有?没有人遇到过这个问题?