小编pro*_*mad的帖子

java.lang.IllegalArgumentException:找不到片段的 id () 视图

我在滑动窗格布局中有一个片段。每个组件都有 id 属性。

<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>
Run Code Online (Sandbox Code Playgroud)

我正在使用 FragmentTransaction 替换其中一个片段。

ft.replace(R.id.candidateSummaryFragment, new NCPCandidateSummaryFragment());
    ft.commit();
Run Code Online (Sandbox Code Playgroud)

但错误它显示了错误。java.lang.IllegalArgumentException:找不到片段 NCPCandidateSummaryFragment{40decd50 #3 id=0x7f0b0074} 的 id 0x7f0b0074 的视图

R.java 也有关于具有相同十六进制和 id 的片段的条目。

layout android fragment sliding fragmenttransaction

1
推荐指数
1
解决办法
8328
查看次数

标签 统计

android ×1

fragment ×1

fragmenttransaction ×1

layout ×1

sliding ×1