I have a fragment inside a sliding pane layout.Every component has id attribute to it.

<FrameLayout
    android:id="@+id/interviewDetailsScreen"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:background="#FFFFFF" />

<LinearLayout
    android:id="@+id/candidateDetailScreen"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:baselineAligned="false"
    android:orientation="horizontal"
    android:weightSum="4" >

    <fragment
        android:id="@+id/candidateSummaryFragment"
        android:name="com.ultimatix.ncp.activity.ui.NCPCandidateSummaryFragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#808080" />

    <fragment
        android:id="@+id/candidateDetailFragment"
        android:name="com.ultimatix.ncp.activity.ui.NCPCandidateDetailsFragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:background="#FFFFFF"
        android:visibility="gone" />
</LinearLayout>

and I am replacing one of the fragments with use of FragmentTransaction.

ft.replace(R.id.candidateSummaryFragment, new NCPCandidateSummaryFragment());
    ft.commit();

But error it shows the error. java.lang.IllegalArgumentException: No view found for id 0x7f0b0074 for fragment NCPCandidateSummaryFragment{40decd50 #3 id=0x7f0b0074}

The R.java also has the entry regarding the fragment with same hex and id.

有帮助吗?

解决方案

May be your current activity does not have this xml file in setContentView(). You must specify a view for fragment that is child of current layout of your activity.

Check setContentView(R.layout.yourlayot) function, I think problem is there.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top