title: Overlapping of fragments when transiting on clicking on an item in RecyclerView of one fragment to another new fragment
body: <p>I am new to android development. The problem is the RecyclerView populated using a firebase database is not replaced by a new fragment, rather the new fragment is on top, but clicking on another item of the recycler view still works, which I checked using a toast in the new fragment. I know that the next fragment is there because I have TextView at the bottom, which is visible on clicking on the recycler view Item.</p>
  <p>Here is my code</p>
  <pre><code>adapter = new FirebaseRecyclerAdapter&lt;Categories, CategoryViewHolder&gt;(options) {
  
              @Override
              protected void onBindViewHolder(@NonNull final CategoryViewHolder holder, int position, @NonNull Categories model)
              {
  
                  Picasso.get().load(model.getImage()).placeholder(R.drawable.camera).into(holder.categoryImage, new Callback() {
                      @Override
                      public void onSuccess()
                      {
  
                      }
  
                      @Override
                      public void onError(Exception e) {
                          Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                      }
                  });
  
                  holder.categoryName.setText(model.getName());
                  holder.categoryImage.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View view) {
                          Toast.makeText(getContext(), holder.categoryName.getText().toString(), Toast.LENGTH_SHORT).show();
  
  //                        Intent intent = new Intent(getActivity(), ProductListActivity.class);
  //                        startActivity(intent);
                          AppCompatActivity activity = (AppCompatActivity) view.getContext();
  
                          SearchFragment fragment = SearchFragment.newInstance(holder.categoryName.getText().toString());
                          FragmentManager fragmentManager = activity.getSupportFragmentManager();
                          FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                          fragmentTransaction.replace(R.id.nav_host_fragment, fragment, SearchFragment.class.getSimpleName());
                          fragmentTransaction.addToBackStack(null);
  
                          fragmentTransaction.commit();
                      }
                  });
  </code></pre>
  <p>The fragment I am using is also used for the navigation drawer using navController.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      app:layout_behavior=&quot;@string/appbar_scrolling_view_behavior&quot;
      tools:showIn=&quot;@layout/app_bar_main&quot;&gt;
  
      &lt;fragment
          android:id=&quot;@+id/nav_host_fragment&quot;
          android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          app:defaultNavHost=&quot;true&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:navGraph=&quot;@navigation/mobile_navigation&quot; /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p><strong>Edit</strong>: I have another recyclerView inside SearchFragment, which didn't show after I clicked an image in the RecyclerView(One which calls SearchFragment). But it showed after I minimized and opened the app again. I don't understand why that is happening.</p>