title: How to start an activity on material navigation drawer menu item clicked
body: <p>I am using collapsible action bar.
  While trying to start new activity got error: Cannot resolve constructor 'Intent(anonymous android.support.design.widget.NavigationView.OnNavigationItemSelectedListener, java.lang.Class)'</p>
  
  <p>Please help me on this:</p>
  
  <p>Can we use start new activity from navigation drawer menu item click ?</p>
  
  <p>Or</p>
  
  <p>We have only option to replace and show fragments from navigation drawer on menu item click</p>
  
  <pre><code>FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
  fragmentTransaction.replace(R.id.containerView,new SentFragment()).commit();
  </code></pre>
  
  <p>if yes, then how can I replace tab activity and viewpager and set action bar height ? </p>
  
  <pre><code>activity_main.xml
  
  &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/drawerLayout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.test.app.activities.MainActivity"&gt;
  
  &lt;android.support.design.widget.CoordinatorLayout
      android:id="@+id/rootLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_width="match_parent"
          android:layout_height="@dimen/app_bar_height"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
  
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="48dp"
              android:minHeight="?attr/actionBarSize"
  
              app:layout_scrollFlags="scroll|enterAlways"
              app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
              app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /&gt;
  
          &lt;android.support.design.widget.TabLayout
              android:id="@+id/tabLayout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              app:tabIndicatorHeight="4dp"
              app:tabGravity="fill"
              app:tabMode="scrollable"
              app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
           &lt;android.support.v4.view.ViewPager
              android:id="@+id/viewpager"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              app:layout_behavior="@string/appbar_scrolling_view_behavior" /&gt;
  
  
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id="@+id/fabBtn"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="bottom|end"
          android:layout_marginBottom="@dimen/fab_margin_bottom"
          android:layout_marginRight="@dimen/fab_margin_right"
          android:src="@drawable/ic_plus"
  
          app:borderWidth="0dp"
          app:fabSize="normal" /&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  
  &lt;android.support.design.widget.NavigationView
      android:id="@+id/navigation"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      app:headerLayout="@layout/nav_header"
      app:itemIconTint="@color/nav_item_icon_tint_color"
      app:itemTextColor="@color/nav_item_text_color"
      app:menu="@menu/navigation_drawer_items" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>MainActivity.java</p>
  
  <pre><code>navigation = (NavigationView) findViewById(R.id.navigation);
      navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(MenuItem menuItem) {
              int id = menuItem.getItemId();
              drawerLayout.closeDrawers();
              switch (id){
                  case R.id.home:
                      //do something here
                      //open new activity
                      /*unable to start activity*/
                      //Intent intent = new Intent(this, NewActivity.class);
                      /* error on above line shown: Cannot resolve constructor 'Intent(anonymous android.support.design.widget.NavigationView.OnNavigationItemSelectedListener, java.lang.Class&lt;com.test.app.activities.RouteActivity&gt;)'*/
                      break;
                  case R.id.logout:
                     //add navigation drawer item onclick method here
                      break;
  
              }
              return false;
          }
      });
  </code></pre>