我正在使用片段,当我在左侧片段上选择某些内容时,我希望我的主要活动创建一个右侧片段。
所以我这样做是为了在 FrameLayout 上添加我的 Fragment :
//add a fragment
FluxDetailFragment myFragment = new FluxDetailFragment();
fragmentTransaction.add(R.id.frameLayout3, myFragment);
fragmentTransaction.commit();
但我得到这个错误:
02-02 15:34:03.104: E/AndroidRuntime(14794): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
我必须先删除我的 FrameLayout 视图吗?还是另一种看法?怎么做?