title: How does this strange condition happens when show menu item icon in toolbar overflow menu?
body: <p>I want to show a overflow menu in toolbar(AppCompat-v7:22.1.1), below is my menu_main.xml.</p>
  <pre><code>&lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  tools:context=&quot;.MainActivity&quot;&gt;
  &lt;item
      android:id=&quot;@+id/action_search&quot;
      android:title=&quot;@string/action_search&quot;
      android:icon=&quot;@mipmap/ic_menu_search&quot;
      android:orderInCategory=&quot;100&quot;
      android:actionViewClass=&quot;android.widget.SearchView&quot;
      app:showAsAction=&quot;ifRoom&quot;/&gt;
  
  &lt;item
      android:id=&quot;@+id/menu_group_chat&quot;
      android:title=&quot;@string/menu_group_chat&quot;
      android:icon=&quot;@mipmap/ic_menu_groupchat&quot; /&gt;
  
  &lt;item
      android:id=&quot;@+id/menu_add_friend&quot;
      android:title=&quot;@string/menu_add_friend&quot;
      android:icon=&quot;@mipmap/ic_menu_add_friend&quot; /&gt;
  </code></pre>
  
  <p>After running my app, the icon of menu item is not displayed, then I tried this <a href="https://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar">solution</a>, add an override method <code>onMenuOpened()</code> in my Activty(extends from <code>AppCompatActivity</code>),</p>
  <pre><code>@Override
  public boolean onMenuOpened(int featureId, Menu menu) {
      if(menu!=null){
          if(menu.getClass().getSimpleName().equals(&quot;MenuBuilder&quot;)){
              try {
                  Method m = menu.getClass().getDeclaredMethod(
                          &quot;setOptionalIconsVisible&quot;, Boolean.TYPE);
                  m.setAccessible(true);
                  m.invoke(menu, true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      return super.onMenuOpened(featureId, menu);
  }
  </code></pre>
  <p>But after running this demo, I find that the icon is still not displayed.</p>
  <p><img src="https://i.stack.imgur.com/yu34v.png" alt="1. Menu with overflow button click" /></p>
  <p>From this <a href="http://code.google.com/p/android/issues/detail?id=171440" rel="nofollow noreferrer">reported issue</a>, I know that <code>AppCompatActivity.onMenuOpened</code> is not called any more in 22.x, but it's odd that when I click the hardware menu key in Genymotion, the menu appear at the bottom and with the icon,</p>
  <p><img src="https://i.stack.imgur.com/UsTrn.png" alt="2. Menu with menu key click" /></p>
  <p>after closing the menu, I click the overflow button in the toolbar again, these icons in menu appear,</p>
  <p><img src="https://i.stack.imgur.com/ETkpF.png" alt="3. Menu with overflow button click" /></p>
  <p>how strange it is! Why this happens?</p>