title: Navigation Menu item click not working
body: <p>I have created a side-menu(Navigation Menu) for my app and have overridden the OnOptionsItemSelected(MenuItem item) method in order to add some custom behavior when each menu item is clicked. However, after writing some code so that when the first menu item is clicked(nav_home &lt;- id) a Toast will be displayed,nothing happens when i click on it and i cannot figure out the problem here...</p>
  
  <pre><code>    @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      if(mToggle.onOptionsItemSelected(item)) {
          return true;
      }
      // When a menu item is clicked, then depending on it's id start a new Activity
      switch (item.getItemId()) {
          case R.id.nav_home:
              Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show();
              break;
          default:
              return super.onOptionsItemSelected(item);
      }
      return true;
  }
  </code></pre>
  
  <p>Here's my whole MainActivity class :</p>
  
  <pre><code>package com.dcv.spdesigns.dokkancards;
  
  import android.content.Intent;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.Toolbar;
  import android.util.DisplayMetrics;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.GridView;
  import android.widget.Toast;
  
  import com.dcv.spdesigns.dokkancards.model.ImageAdapter;
  import com.dcv.spdesigns.dokkancards.ui.CardViewActivity;
  
  public class MainActivity extends AppCompatActivity {
  GridView gridView;
  
  // NavMenu member vars
  private DrawerLayout mDrawerLayout;
  private ActionBarDrawerToggle mToggle; // Button for toggling the side menu
  
  private Toolbar mToolbar;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      // Get Screen Size Details
      DisplayMetrics displayMetrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
      int height = displayMetrics.heightPixels;
      final int width = displayMetrics.widthPixels;
  
      gridView = (GridView) findViewById(R.id.gridViewLayout);
      gridView.setAdapter(new ImageAdapter(this)); // used to set the contents of the GridView-in this case images-
  
      // When an item from the GridView gets clicked
      gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              // Create a new Intent...
              Toast.makeText(MainActivity.this, "Position: " + position, Toast.LENGTH_SHORT).show();
              Intent intent = new Intent(MainActivity.this,CardViewActivity.class);
              intent.putExtra("Card Index",position);
              intent.putExtra("SCREEN_WIDTH",width);
              startActivity(intent);
          }
      });
  
      mToolbar = (Toolbar) findViewById(R.id.navActionBar);
      setSupportActionBar(mToolbar); // check quick doq
      getSupportActionBar().setDisplayShowTitleEnabled(false);
      mToolbar.setTitle("");
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
      mToggle = new ActionBarDrawerToggle(this,mDrawerLayout,R.string.drawer_open,R.string.drawer_closed); // Instantiating our button
  
      mDrawerLayout.addDrawerListener(mToggle);
      mToggle.syncState();
  
  
  }
  
  // When an item from the Action Bar gets tapped, then...
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      if(mToggle.onOptionsItemSelected(item)) {
          return true;
      }
      // When a menu item is clicked, then depending on it's id start a new Activity
      switch (item.getItemId()) {
          case R.id.nav_home:
              Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show();
              break;
          default:
              return super.onOptionsItemSelected(item);
      }
      return true;
  }
  }
  </code></pre>
  
  <p>Main xml file:</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:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/colorPrimary"
      tools:context="com.dcv.spdesigns.dokkancards.MainActivity"
      android:id="@+id/drawerLayout"&gt;
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;!-- Include the custom Action Bar we created --&gt;
  
      &lt;include layout="@layout/navigation_action_bar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center"/&gt;
  
      &lt;GridView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:columnWidth="90dp"
          android:numColumns="4"
          android:verticalSpacing="10dp"
          android:horizontalSpacing="10dp"
          android:stretchMode="columnWidth"
          android:gravity="center"
          android:id="@+id/gridViewLayout"/&gt;
  
      &lt;!-- Add text &amp; images --&gt;
  &lt;/LinearLayout&gt;
  
  &lt;!-- The actual side menu Nav View --&gt;
  &lt;android.support.design.widget.NavigationView
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      app:headerLayout="@layout/navigation_header"
      app:menu="@menu/navigation_menu"&gt;
  
  &lt;/android.support.design.widget.NavigationView&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>