这是我的平板电脑肖像和风景的布局设计
-
人像布局
-
菜单导航抽屉和
-
内容片段
-
景观布局(双窗格)
-
左侧菜单片段
-
内容碎片在右边
我正在使用支持库导航抽屉 android.support.v4.widget.DrawerLayout
用例:
-
App以横向模式启动
-
横向布局 - 双窗格被充气并加载数据
-
方向已更改
-
菜单片段被破坏和分离
-
纵向布局 - 内容片段膨胀的导航抽屉
-
Navigation drawer attached to activity and detached immediately
-
*** Because Landscape Menu Fragment is re-created by the system and attached to the activity.***
-
App crashes because Navigation Drawer is detached
我尝试了一个由stackoverflow用户goRGon建议的solution,它似乎工作 .
But need your suggestions whether this is the best way to stop a fragment recreation ?