从另一个片段调用一个片段错误?

时间:2013-12-13 13:33:09

标签: android android-fragments

我从其他名为CommonHome的片段中调用了一个名为MilkingFragment的片段,我使用了这段代码

            Fragment fragment=new MilkingFragment("me");

    Bundle args = new Bundle();
    args.putInt(DummySectionFragment.ARG_SECTION_NUMBER,  1);
    fragment.setArguments(args);

            getChildFragmentManager().beginTransaction()
            .replace(R.id.content_frame, fragment).commit();

但它的显示错误正在崩溃。我该怎么解决这个问题呢。

错误是

 12-13 18:54:52.931: E/AndroidRuntime(6692): FATAL EXCEPTION: main
 12-13 18:54:52.931: E/AndroidRuntime(6692): java.lang.IllegalArgumentException: No 
    view found for id 0x7f0a0001 (com.tcs.ignite.pashupalan:id/content_frame) for  
 fragment  MilkingFragment{41aba808 #0 id=0x7f0a0001}
12-13 18:54:52.931: E/AndroidRuntime(6692):     at    
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
12-13 18:54:52.931: E/AndroidRuntime(6692):     at 
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)

12-13 18:54:52.931: E/AndroidRuntime(6692):     at   
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
 12-13 18:54:52.931: E/AndroidRuntime(6692):    at     

android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
12-13 18:54:52.931: E/AndroidRuntime(6692):     at 
 android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
 12-13 18:54:52.931: E/AndroidRuntime(6692):    at 
 android.os.Handler.handleCallback(Handler.java:605)

1 个答案:

答案 0 :(得分:0)

看起来您正在尝试将您的片段添加到不存在的容器中。

,即您的布局没有名为content_frame

的视图