title: Popup menu on click of a button in action Bar
body: <p>I am trying to implement an action bar in which one of the buttons on click shows a popup menu.
  Here's the menu. XML (menu items in the action bar)</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
  &lt;item
      android:id="@+id/search"
      android:icon="@drawable/ic_action_search"
      android:orderInCategory="0"
      android:showAsAction="always"
      android:title="@string/menu_search"/&gt;
  &lt;item
      android:id="@+id/refresh"
      android:icon="@drawable/ic_action_refresh"
      android:orderInCategory="1"
      android:showAsAction="always"
      android:title="@string/menu_refresh"/&gt;
  
  
   &lt;Item
      android:id="@+id/popup"
      android:icon="@drawable/ic_action_search"
      android:onClick="showPopup"
      android:orderInCategory="1"
      android:showAsAction="always"
      android:title="@string/menu_search" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>I wish to show a popup menu on the click of the item having id "@+id/popup". </p>
  
  <p>here is the XML for the popup menu</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
  &lt;item
      android:id="@+id/item1"
      android:icon="@drawable/ic_action_search"
      android:orderInCategory="0"
      android:showAsAction="always"
      android:title="@string/menu_search"/&gt;
  &lt;item
      android:id="@+id/item2"
      android:icon="@drawable/ic_action_search"
      android:orderInCategory="1"
      android:showAsAction="always"
      android:title="@string/menu_search"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>here is the onClick method for the button</p>
  
  <pre><code>public void showPopup(View v) {
      PopupMenu popup = new PopupMenu(this, v);
      MenuInflater inflater = popup.getMenuInflater();
      inflater.inflate(R.menu.overflow, popup.getMenu());
      popup.show();
  }
  </code></pre>
  
  <p>And the problem is that no popup shows up on click of that button. Need help folks.</p>