JakeWharton/ActionBarSherlock — Issue #185: Focus/selected state maintained on MenuItem.setIcon()
Author: carlospuk
Created: 2012-01-14 17:33:22+00:00
State: open

Steps to reproduce:

1. Programatically change the icon of a MenuItem that is already displayed in the action bar. (in my case, it was on the bottom bar, i.e. a split action bar)

2. In some cases, the action item's background remains 'focussed', i.e. it has a dark blue rectangular background.

Example code:

MenuItem myItem;

...

@Override
public boolean onCreateOptionsMenu(Menu menu) {

MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.busstopmenu, menu);

// Store relevant menu item
this.myItem= menu.findItem(R.id.mnubusstop_favestar);

return super.onCreateOptionsMenu(menu);
}

....

void changeIcon()
{
this.myItem.setIcon(R.drawable.new_image);
}