title: Android Java Bottom Navigation Bar Fragment not showing
body: <p>I'm trying to implement a bottom navigation bar, however even though all the functions are called, the fragment view is not shown.
  Here is my code, please point out what I'm doing wrong or missing.
  I'm only testing it for one fragment at the time. Below given code is for the activity, a fragment and the activity layout.</p>
  <p><strong>Main Activity</strong></p>
  <pre><code>public class mActivity extends AppCompatActivity {
  BottomNavigationView bottomNavigationView;
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.m_activity);
      bottomNavigationView = findViewById(R.id.navigationbar);
      bottomNavigationView.setSelectedItemId(R.id.profilenav);
      bottomNavigationView.setOnNavigationItemSelectedListener(listener);
      loadFragment(new HomeFragment());
  }
  
  private final BottomNavigationView.OnNavigationItemSelectedListener listener = new BottomNavigationView.OnNavigationItemSelectedListener() {
      @SuppressLint(&quot;NonConstantResourceId&quot;)
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {
          switch (item.getItemId()) {
              case R.id.explorenav:
                  //Load explore fragment here
                  break;
              case R.id.profilenav:
                  loadFragment(new HomeFragment());
                  Log.d(&quot;HomeFragment&quot;,&quot;Selected&quot;);
                  return true;
          }
          return false;
      }
  };
  
  private void loadFragment(Fragment fragment) {
      // load fragment
      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      transaction.replace(R.id.m_fragment, fragment);
      transaction.addToBackStack(null);
      transaction.commit();
      Log.d(&quot;mActivity&quot;,&quot;loadfragment()&quot;);
  }
  </code></pre>
  <p><strong>Fragment</strong></p>
  <pre><code>public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          Log.d(&quot;HomeFragment&quot;,&quot;onCreateView Start&quot;);
          super.onCreateView(inflater,container,savedInstanceState);
          View v= inflater.inflate(R.layout.home_activity, container, false);
      return v;
  }
  </code></pre>
  <p><strong>m_activity.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.appcompat.widget.LinearLayoutCompat
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;include
          android:id=&quot;@+id/includenav&quot;
          layout=&quot;@layout/bottom_navigation_bar&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_margin=&quot;1dp&quot;
          android:layout_gravity=&quot;bottom&quot;
          /&gt;
      &lt;FrameLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_margin=&quot;3dp&quot;
          android:id=&quot;@+id/m_fragment&quot;
          /&gt;
  &lt;/androidx.appcompat.widget.LinearLayoutCompat&gt;
  </code></pre>
  <p><strong>bottom_navigation_bar.xml</strong>
  The code for the included layout:</p>
  <pre><code>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
  
  &lt;com.google.android.material.bottomnavigation.BottomNavigationView
      android:id=&quot;@+id/navigationbar&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;50dp&quot;
      android:layout_gravity=&quot;bottom&quot;
      android:background=&quot;?android:attr/windowBackground&quot;
      android:foreground=&quot;?attr/selectableItemBackground&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintHorizontal_bias=&quot;0.0&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot;
      app:layout_constraintVertical_bias=&quot;0.994&quot;
      app:menu=&quot;@menu/navigation&quot; /&gt;
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>This is the main code file, However the layout is not updated in the m_fragment frame layout.</p>