Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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_Screen Rotation - Fatal编程技术网

Android 控制细节片段旋转

Android 控制细节片段旋转,android,android-fragments,screen-rotation,Android,Android Fragments,Screen Rotation,我的活动中有一个主片段和一个细节片段。在横向模式下,两个片段相邻显示。在纵向模式下,我打开一个新的活动,在主片段交互时只保存细节片段。 像这样: if(findViewById(R.id.detail_fragment_placeholder).getVisibility() == View.VISIBLE) { detailFragment.update(content); } else { Intent intent = new Intent(TwoFragmentActiv

我的活动中有一个主片段和一个细节片段。在横向模式下,两个片段相邻显示。在纵向模式下,我打开一个新的活动,在主片段交互时只保存细节片段。 像这样:

if(findViewById(R.id.detail_fragment_placeholder).getVisibility() == View.VISIBLE) {
    detailFragment.update(content);
} else {
    Intent intent = new Intent(TwoFragmentActivityImplementation.this, FragmentActivity.class);
    startActivity(intent);
}
我的问题是,如果用户将屏幕旋转回横向模式,而只有细节片段可见,则细节片段将旋转到横向模式,而主片段不会显示(由于明显的原因,因为主片段不存在于此活动中)

我的问题是如何处理这个场景,如何在保留单片段活动的片段状态的同时返回到双片段活动?我认为在肖像中打开一个新的单片段活动是推荐的方法。我错了吗

谢谢你的意见