Get the ActionBar to redraw itself?
<p>I'd like to replace the icon used for an ActionBar item at runtime (it appears as an action item on the ActionBar). I'm trying the following:</p>

<pre><code>private Map&lt;Integer, Integer&gt; mPendingReplacements = 
    new HashMap&lt;Integer, Integer&gt;();

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.my_menu, menu);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    for (Map.Entry&lt;Integer, Integer&gt; it : mPendingReplacements.entrySet()) {
        MenuItem item = menu.findItem(it.getKey().intValue());
        if (item != null) {
            item.setIcon(getResources().getDrawable(it.getValue().intValue()));
        }
    }
    mPendingReplacements.clear();

    return true;
}

private void replaceMenuItemIcon(int menuItemId, int drawable) {
    mPendingReplacements.put(menuItemId, drawable);
    invalidateOptionsMenu();
} 

private void onUserClickedSomeButton() {
    replaceMenuItemIcon(R.id.foo, R.drawable.grok);    
}
</code></pre>

<p>------------ Update -----------</p>

<p>Updated the above sample to use mPendingReplacements as suggested by Selvin. I can see it execute as excepted, but the actionbar icon still doesn't change immediately. Will continue digging into this, but can anyone spot if I'm missing something?</p>

<p>Thank you</p>
