Я использую реселлервью. Тогда проблема в том, что когда я щелкаю одну из строк, новый фрагмент должен быть открыт. Он открывается, но старый фрагмент все еще появляется. это мой скриншот: ![enter image description here](https://i.stack.imgur.com/3tscf.png)
Как видите, когда я нажимаю «opel», открывается новый фрагмент. Но это частично совпадает.
Это мой фрагмент 1:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvarackategori"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container">
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Это мой новый фрагмент:
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".ui.aracYedekParca.chevrolet.ChevroletYedekParcaFragment">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Chevrolet Yedek Parca" />
</FrameLayout>
Это мой код:
override fun userItemClick(position: Int) {
//super.userItemClick(position) No need of it.
when (position) {
0 -> {
var fragmentOpel=OpelYedekParcaFragment()
var transaction = manager.beginTransaction()
transaction.replace(R.id.container,fragmentOpel)
transaction.commit()
Log.e("aki", "opel: " + position)
} //start a fragment
1 -> {
var fragmentChevrolet=ChevroletYedekParcaFragment()
var transaction = manager.beginTransaction()
transaction.replace(R.id.container,fragmentChevrolet)
transaction.commit()
Log.e("aki", "chevrolet: " + position)
} //start a fragment