title: Android invalidateOptionsMenu() for API < 11
body: <p>I used <code>ActivityCompat.invalidateOptionsMenu(MainActivity.this);</code> so that my menu item "refresh"  can automatically be enabled/disabled without the using have to touch the "Menu" option (imagine the user leaves the Menu open... I need the "Refresh" menu item to automatically disabled and enable itself). </p>
  
  <p>The <code>ActivityCompat.invalidateOptionsMenu(MainActivity.this)</code> works fine in Android 11+. But what can I use for android API &lt; 11 ? :S I've searched so much but I cannot find an answer. Can anyone please help me on this? </p>
  
  <p>This works fine in Android API 11+, using the <code>onPrepareOptionsMenu</code> and <code>ActivityCompat.invalidateOptionsMenu(MainActivity.this)</code>. 
  The issue is trying to get it done in Android API &lt; 11.</p>
  
  <p>Here is my <code>onPrepareOptionsMenu</code> method: </p>
  
  <pre><code>@Override
  public boolean onPrepareOptionsMenu(Menu menu) {
      if(menuRefreshEnable){
          menu.getItem(0).setEnabled(true);
      }
      if(!menuRefreshEnable){
          menu.getItem(0).setEnabled(false);
      }       
      return true;
  }
  </code></pre>