1
我正在使用片段,並且當我在左側片段上選擇某個內容時,我想要通過我的主要活動創建正確的片段。在我的活動中動態添加片段
所以我這樣做是爲了增加對我的FrameLayout片段:
//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看法?還是另一種觀點?如何做?
你可以把FluxDetailFragment的onCreate和onCreateView放在這裏嗎? – 2012-02-02 15:26:42
從我自己的錯誤,我用根膨脹而不是「空」 – Thordax 2012-02-06 17:42:46