title: Adding an app bar to a bottom navigation activity
body: <p>I want to add an app bar to my app which has a bottom navigation bar. I followed the android developer's help and here is what I made in my activity:</p>
  
  <pre><code>public class BetsActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_bets);
      BottomNavigationView bottomNavigationView = (BottomNavigationView)
              findViewById(R.id.navigation);
  
      bottomNavigationView.setOnNavigationItemSelectedListener
              (new BottomNavigationView.OnNavigationItemSelectedListener() {
                  @Override
                  public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                      Fragment selectedFragment = null;
                      switch (item.getItemId()) {
                          case R.id.navigation_p1:
                              selectedFragment = p1.newInstance();
                              Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
                              setSupportActionBar(myToolbar);
                              break;
                          case R.id.navigation_p2:
                              selectedFragment = p2.newInstance();
                              myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
                              setSupportActionBar(myToolbar);
                              break;
                      }
                      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                      transaction.replace(R.id.frame_layout, selectedFragment);
                      transaction.commit();
                      return true;
                  }
              });
  
      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      transaction.replace(R.id.frame_layout, p1.newInstance());
      transaction.commit();
  }
  </code></pre>
  
  <p>Activity's layout:</p>
  
  <pre><code>&lt;RelativeLayout
      android:id="@+id/activity_main"
      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"
      tools:context="com.example.carbet.BetsActivity"&gt;
  
      &lt;FrameLayout
          android:id="@+id/frame_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_above="@+id/navigation"
          android:animateLayoutChanges="true"&gt;
  
      &lt;/FrameLayout&gt;
  
      &lt;android.support.design.widget.BottomNavigationView
          android:id="@+id/navigation"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:background="@color/colorPrimary"
          app:itemTextColor="@android:color/white"
          app:itemIconTint="@android:color/white"
          app:menu="@menu/navigation" /&gt;
  
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/my_toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          android:elevation="4dp"
          android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And here is my app manifest:</p>
  
  <pre><code>&lt;application
      android:allowBackup="true"
      android:icon="@mipmap/logo_car_bet"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/logo_car_bet"
      android:supportsRtl="true"
      android:theme="@style/AppTheme.NoActionBar"&gt;
  
      &lt;meta-data
          android:name="com.google.firebase.messaging.default_notification_icon"
          android:resource="@mipmap/logo_car_bet" /&gt;
  
      &lt;meta-data
          android:name="com.google.firebase.messaging.default_notification_color"
          android:resource="@color/colorAccent" /&gt;
  
      &lt;activity
          android:name=".MainActivity"
          android:label="Car Bet"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".BetsActivity"
          android:label="@string/title_activity_bets"
          android:parentActivityName=".MainActivity"/&gt;
  
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value=".MainActivity" /&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p>I use fragments for the bottom nav bar but I don't do anything in their files.
  When I launch it, first it shows a green bar, but without any title nor overflow menu. When I go to the other fragment, title appear but not the menu.
  Please tell me which error(s) I made.</p>