title: How to use on click listener on menu items?
body: <p>Instead of using toast , i want to use on click listener in the menu items, and can we use fragments in this case
  this is the following code in which i want to add on click, so i can open in a new activity</p>
  
  <p>// Initiating Menu XML file (menu.xml)</p>
  
  <pre><code> @Override
      public boolean onCreateOptionsMenu(Menu menu)
      {
          MenuInflater menuInflater = getMenuInflater();
          menuInflater.inflate(R.layout.menu, menu);
          return true;
      }
  
      /**
       * Event Handling for Individual menu item selected
       * Identify single menu item by it's id
       * */
      @Override
      public boolean onOptionsItemSelected(MenuItem item)
      {
  
          switch (item.getItemId())
          {
          case R.id.menu_bookmark:
              // Single menu item is selected do something
              // Ex: launching new activity/screen or show alert message
              Toast.makeText(AndroidMenusActivity.this, "Bookmark is Selected", Toast.LENGTH_SHORT).show();
              return true;
  
          case R.id.menu_save:
              Toast.makeText(AndroidMenusActivity.this, "Save is Selected", Toast.LENGTH_SHORT).show();
              return true;
  
          case R.id.menu_search:
              Toast.makeText(AndroidMenusActivity.this, "Search is Selected", Toast.LENGTH_SHORT).show();
              return true;
  
          case R.id.menu_share:
              Toast.makeText(AndroidMenusActivity.this, "Share is Selected", Toast.LENGTH_SHORT).show();
              return true;
  
          case R.id.menu_delete:
              Toast.makeText(AndroidMenusActivity.this, "Delete is Selected", Toast.LENGTH_SHORT).show();
              return true;
  
          case R.id.menu_preferences:
              Toast.makeText(AndroidMenusActivity.this, "Preferences is Selected", Toast.LENGTH_SHORT).show();
              return true;
  
          default:
              return super.onOptionsItemSelected(item);
          }
      }    
  
  }
  </code></pre>