title: how to get the OnClick event of Option menu button in Sherlock ActionBar in Android?
body: <p>I am working on <strong>Sherlock ActionBar</strong> and using an Option button at right corner, near search icon. I am successful to generate the onClick event for SEARCH button but I am getting problems in onClick event of the option Button. 
  Using the below code to add the buttons :</p>
  
  <pre><code>public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
          menu.add(0, 1, 1, "Search").setIcon(R.drawable.search_icon).setActionView(R.layout.action_search).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
          menu.add(0, 2, 2, "Button").setIcon(R.drawable.menu_overflow_icon).setActionView(R.layout.action_button).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
  return super.onCreateOptionsMenu(menu);
      }
  </code></pre>
  
  <p>And for click events :</p>
  
  <pre><code>@Override
      public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
          switch (item.getItemId()) {
          case 1:
              search = (EditText) item.getActionView();
              search.addTextChangedListener(filterTextWatcher);
              search.requestFocus();
              InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
      break;
          case 2:
              Toast.makeText(ActivityScreen.this, "hit it", Toast.LENGTH_SHORT).show();
  
  
          }
          return super.onOptionsItemSelected(item);   
      }       
  </code></pre>
  
  <p>I have shown my requirement in the image attached below.
  <img src="https://i.stack.imgur.com/6mRwV.png" alt="enter image description here"></p>