【发布时间】:2013-04-04 14:27:27
【问题描述】:
我定义了活动和两个布局:
- 大地布局
- 布局
第一种布局适用于横向模式下的大屏幕,第二种布局适用于其他情况。 第一个布局包含:
- 片段1
- 片段2
第二个布局包含:
- 片段1
当我在大屏幕上以横向模式启动应用程序时,Activity.onCreate() 中调用的 getSupportFragmentManager().findFragmentById() 正确返回两个片段。将方向更改为纵向后,getSupportFragmentManager().findFragmentById() 为 fragment2 返回非 null,但它应该返回 null,因为此布局中未定义此片段。问题是返回的片段对象不正确,我在访问它时得到null 指针异常。应该是null,不是吗?
【问题讨论】:
标签: android fragment android-orientation