【发布时间】:2019-05-05 18:07:37
【问题描述】:
当我点击 recyclerView 中的项目时如何替换片段
我在适配器的onClickListener里面试过了
childFragmentManager
.beginTransaction()
.replace(R.id.framefragment2, Fragment2())
.commit()
没有成功它返回我
java.lang.IllegalArgumentException: No view found for id 0x7f0a0137 (com.test.justaapp:id/framefragment1) for fragment Fragmetnone{1ebd5fc #0 id=0x7f0a0137}
这是第一个片段的 mi xml 已经膨胀
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/framefragment1"
android:layout_width="match_parent"
android:layout_height="match_parent">
和第二帧布局
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C0C0C0">
<FrameLayout
android:id="@+id/framefragment2"
android:layout_width="match_parent"
android:layout_height="match_parent">
我一直在寻找几个小时,但无法让它工作,有什么想法吗?也许我在模仿一些非常简单的事情,任何帮助都会非常感谢。
【问题讨论】:
标签: android-fragments kotlin android-recyclerview