title: How to switch between tabs in BottomNavigationView programmatically in AndroidX?
body: <p>I'm using the following activity layout with a <code>fragment</code> and a <code>BottomNavigationView</code>:</p>
  
  <pre><code>&lt;LinearLayout 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"
      android:orientation="vertical"&gt;
  
      &lt;fragment
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:id="@+id/fragment"
          android:name="androidx.navigation.fragment.NavHostFragment"
          app:navGraph="@navigation/navigation_bottom"
          app:defaultNavHost="true"/&gt;
  
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/bottom_navigation_view"
          app:menu="@menu/bottom_navigation_menu"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And have defined three fragments in my navigation layout:</p>
  
  <pre><code>&lt;navigation
      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:id="@+id/navigation_bottom"
      app:startDestination="@id/firstFragment"&gt;
  
      &lt;fragment
          android:id="@+id/firstFragment"
          android:name="fragments.FirstFragment"
          android:label="fragment_first"
          tools:layout="@layout/fragment_first" /&gt;
  
      //The other two fragments
  &lt;/navigation&gt;
  </code></pre>
  
  <p>Inside my activity, I'm using the following code:</p>
  
  <pre><code>navController = Navigation.findNavController(this, R.id.fragment);
  BottomNavigationView bnw = findViewById(R.id.bottom_navigation_view);
  NavigationUI.setupWithNavController(bnw, navController);
  NavigationUI.setupActionBarWithNavController(this, navController);
  </code></pre>
  
  <p>And this my <code>onSupportNavigateUp</code> method:</p>
  
  <pre><code>@Override
  public boolean onSupportNavigateUp() {
      return Navigation.findNavController(this, R.id.fragment).navigateUp();
  }
  </code></pre>
  
  <p>But when I press on the second icon (fragment) nothing happens. How to solve this issue? Thanks!</p>