3
votes

Since I only changed from buttons to RecyclerView (and it worked just fine with the buttons), I know my java code is working fine, so now I face a problem because clicking a cards in the RecyclerView calls the fragment with the FragmentManager, but not showing it. Here is my activity.xml code.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".mainSearch"
        android:background="#f2f2f2">

        <androidx.recyclerview.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/recyclerView"
            android:orientation="horizontal" />

    </androidx.constraintlayout.widget.ConstraintLayout>
    <fragment
        android:name="com.diamcom.blue.StoneCodeFragment"
        android:id="@+id/fragment_place"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </fragment>
</LinearLayout>

I wonder what am I doing wrong ?

1

1 Answers

1
votes

I think the issue you have here is having both the recyclerview and the fragment as match_parent for both width and height. A way I think you can do that is by wrapping the containerview which holds the recyclerview and the fragment in a framelayout and making the containerview to be gone when you click on any of the cards in the recyclerview.