title: Default fragment in activity
body: <p>I've seen many posts on this matter, but I can't figure it out for my code. I have created a tabbed activity and set three buttons at the bottom. The buttons switch between different fragments. A button in a MainActivity opens this tabbed activity, but the problem is that the fragment layout is empty (see image below).</p>
  
  <p>The buttons work perfectly and send me to the right fragments, but when it opens, no fragments are loaded.  </p>
  
  <p><a href="https://i.stack.imgur.com/jxiqr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jxiqr.png" alt="enter image description here"></a></p>
  
  <p>The code, which I build following an YouTube tutorial looks like this:</p>
  
  <p>TabbedActivity.class</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.support.design.widget.BottomNavigationView;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v7.app.AppCompatActivity;
  import android.view.MenuItem;
  
  public class TabbedActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_tabbed_activity);
  
          BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
          navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
      }
  
      private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
              = new BottomNavigationView.OnNavigationItemSelectedListener() {
  
  
          @Override
          public boolean onNavigationItemSelected(@NonNull MenuItem item) {
              android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
              android.support.v4.app.FragmentTransaction transaction = fragmentManager.beginTransaction();
              int intentFragment = getIntent().getExtras().getInt("frgToLoad");
              switch (item.getItemId()) {
                  case R.id.navigation_home:
                      transaction.replace(R.id.content,new Fragment_B1()).commit();
  /*                    mTextMessage.setText(R.string.title_home);*/
                      return true;
                  case R.id.navigation_dashboard:
                      transaction.replace(R.id.content,new Fragment_B2()).commit();
                      /*mTextMessage.setText(R.string.title_dashboard);*/
                      return true;
                  case R.id.navigation_notifications:
                      transaction.replace(R.id.content,new Fragment_B3()).commit();
                      /*mTextMessage.setText(R.string.title_notifications);*/
                      return true;
  
              }
              return false;
          }
      };
  
  }
  </code></pre>
  
  <p>The fragments have the same code pattern inside, which is basic and it makes no point to add it here. The xml of the TabbedActivity looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;android.support.constraint.ConstraintLayout 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/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="TabbedActivity"&gt;
  
      &lt;FrameLayout
          android:id="@+id/content"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_constraintTop_toBottomOf="@+id/appbar"&gt;
  
      &lt;/FrameLayout&gt;
  
      &lt;android.support.design.widget.BottomNavigationView
          android:id="@+id/navigation"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginEnd="0dp"
          android:layout_marginStart="0dp"
          android:background="?android:attr/windowBackground"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:menu="@menu/navigation" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>Can anyone help me to figure out how to open Fragment_B1 by default? I have tried adding the code from the best answer from <a href="https://stackoverflow.com/questions/33670806/how-to-set-default-fragment-of-naviagationdrawer-on-oncreate-activity">here</a>, but still doesn't work. </p>