我在Honeycomb开发了一个应用程序,我正在使用片段.
这是我的应用程序
我的问题是什么
当用户旋转设备时,重新创建活动并使F1成为片段对象,即使在旋转之前它不是
我使用但它对我不起作用
我已经在我的函数中添加了代码片段,就像这样
What is the way to retain the fragment object while rotating?setRetainInstance(true);onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
Fragment homeFragment = new Home();
fragmentTransaction.add(R.id.mainFragement, homeFragment);
fragmentTransaction.commit();
}
Run Code Online (Sandbox Code Playgroud) android screen-rotation android-fragments android-3.0-honeycomb