title: How to set On Click Listener to menu item in android studio
body: <p>I try to set share item using Navigation Drawer Activity in android studio,</p>
  
  <pre><code> &lt;menu&gt;
          &lt;item
              android:id="@+id/navShare"
              android:icon="@drawable/ic_menu_share"
              android:title="Share" /&gt;
  </code></pre>
  
  <p>this is the <code>xml</code> code for that.</p>
  
  <p>problem was come when I try to write java code for this propose,
  problem is what is the typecast type of this <code>navShare</code> menu item in this java code.</p>
  
  <pre><code>} else if (id == R.id.navShare) {
  
                 share  = () findViewById (R.id.navShare);
          share.setOnClickListener(new View.OnClickListener(){
  
          public void onClick(View v){
              Intent shareIntent = new Intent (Intent.ACTION_SEND);
              shareIntent.setType("text/plain");
              String shareBody = "your body here";
              String shareSub = "Your subject here";
              shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSub);
              shareIntent.putExtra (Intent.EXTRA_TEXT, shareBody);
              startActivity (Intent.createChooser (shareIntent,"Share App Locker"));
  </code></pre>