title: How to create a listener for bottom navigation and navigation drawer in the same activity?
body: <p>//Here is my java code</p>
  
  <pre><code>public class HomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
  
      BottomNavigationView bottomNavigationView;
      NavigationView navigationView;
  
      private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
              switch (item.getItemId()) {
                  case R.id.home:
                      HomeFragment homeFragment=new HomeFragment();
                      android.support.v4.app.FragmentTransaction fragmentTransaction=getSupportFragmentManager().beginTransaction();
                      fragmentTransaction.replace(R.id.frameLayout,homeFragment).commit();
                      return true;
  
                  case R.id.navigation_stylist:
                      StylistFragment stylistsFragment=new StylistFragment();
                      android.support.v4.app.FragmentTransaction fragmentTransaction1=getSupportFragmentManager().beginTransaction();
                      fragmentTransaction1.replace(R.id.frameLayout,stylistsFragment).commit();
                      return true;
  
                  case R.id.navigation_apps:
                      MyapptsFragment myaaptsFragment=new MyapptsFragment();
                      android.support.v4.app.FragmentTransaction fragmentTransaction2=getSupportFragmentManager().beginTransaction();
                      fragmentTransaction2.replace(R.id.frameLayout,myaaptsFragment).commit();
                      return true;
  
                  case R.id.navigation_tips:
                      HairtipsFragment hairtipsFragment=new HairtipsFragment();
                      android.support.v4.app.FragmentTransaction fragmentTransaction3=getSupportFragmentManager().beginTransaction();
                      fragmentTransaction3.replace(R.id.frameLayout,hairtipsFragment).commit();
                      return true;
  
                  case R.id.navigation_account:
                      AccountFragment accountFragment=new AccountFragment();
                      android.support.v4.app.FragmentTransaction fragmentTransaction4=getSupportFragmentManager().beginTransaction();
                      fragmentTransaction4.replace(R.id.frameLayout,accountFragment).commit();
  
                      return true;
              }
              return false;
          }
      };
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          //start onboarding when app is opening first time
          isUserFirstTime = Boolean.valueOf(Utils.readSharedSetting(HomeActivity.this, PREF_USER_FIRST_TIME, "true"));
          Intent introIntent = new Intent(HomeActivity.this, OnboardingActivity.class);
          introIntent.putExtra(PREF_USER_FIRST_TIME, isUserFirstTime);
  
          if (isUserFirstTime)
              startActivity(introIntent);
  
          setContentView(R.layout.activity_home);
  
          bottomNavigationView = findViewById(R.id.bottom_navigation);
          navigationView=findViewById(R.id.nav_drawer);
  
  
          //bottom navigationview listener
          bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
          BottomNavigationViewHelper.disableShiftMode(bottomNavigationView);
  
          //navigation drawer listener
          navigationView.setNavigationItemSelectedListener(this);
  
  
          //open home fragment on first launch
          HomeFragment homeFragment=new HomeFragment();
          android.support.v4.app.FragmentTransaction fragmentTransaction=getSupportFragmentManager().beginTransaction();
          fragmentTransaction.replace(R.id.frameLayout,homeFragment).commit();
  
      }
  
  
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {
          switch (item.getItemId()) {
              case R.id.nav_home:
                  HomeFragment homeFragment=new HomeFragment();
                  android.support.v4.app.FragmentTransaction fragmentTransaction=getSupportFragmentManager().beginTransaction();
                  fragmentTransaction.replace(R.id.frameLayout,homeFragment).commit();
                  return true;
  
              case R.id.nav_products:
                  StylistFragment stylistsFragment=new StylistFragment();
                  android.support.v4.app.FragmentTransaction fragmentTransaction1=getSupportFragmentManager().beginTransaction();
                  fragmentTransaction1.replace(R.id.frameLayout,stylistsFragment).commit();
                  return true;
  
              case R.id.nav_promotions:
                  MyapptsFragment myaaptsFragment=new MyapptsFragment();
                  android.support.v4.app.FragmentTransaction fragmentTransaction2=getSupportFragmentManager().beginTransaction();
                  fragmentTransaction2.replace(R.id.frameLayout,myaaptsFragment).commit();
                  return true;
  
              case R.id.nav_purchases:
                  HairtipsFragment hairtipsFragment=new HairtipsFragment();
                  android.support.v4.app.FragmentTransaction fragmentTransaction3=getSupportFragmentManager().beginTransaction();
                  fragmentTransaction3.replace(R.id.frameLayout,hairtipsFragment).commit();
                  return true;
  
              case R.id.nav_settings:
                  AccountFragment accountFragment=new AccountFragment();
                  android.support.v4.app.FragmentTransaction fragmentTransaction4=getSupportFragmentManager().beginTransaction();
                  fragmentTransaction4.replace(R.id.frameLayout,accountFragment).commit();
                  return true;
          }
          return false;
      }
  }
  </code></pre>
  
  <p>// Here is my xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout
      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/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:openDrawer="start"&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_drawer"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:fitsSystemWindows="true"
          app:theme="@style/menu_text_style"
          app:menu="@menu/navigation_drawer" /&gt;
  
      &lt;!--app:headerLayout="@layout/nav_header_main"--&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;FrameLayout
              android:id="@+id/frameLayout"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_above="@+id/shadow"
              android:animateLayoutChanges="true"&gt;
  
          &lt;/FrameLayout&gt;
  
          &lt;View
              android:id="@+id/shadow"
              android:layout_width="match_parent"
              android:layout_height="@dimen/_1sdp"
              android:layout_above="@id/bottom_navigation"
              android:background="@color/shadow"/&gt;
  
  
          &lt;android.support.design.widget.BottomNavigationView
              android:id="@+id/bottom_navigation"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              app:itemIconTint="@color/navigationitem"
              app:itemTextColor="@color/navigationitem"
              app:menu="@menu/navigation_item"/&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>I want to create both navigation drawer and bottom navigation in the same activity. I created <code>XML</code> design now I have to write java code for both. Bottom navigation is working perfectly but navigation item <code>clicklistener</code> is not working. I created fragments for navigation drawer and also for bottom navigation. When I click the items in navigation drawer it's not redirecting to respective fragment. The given <code>clicklistener</code> for navigation drawer is not at all working.</p>