I have an Activity which has an ActionBar but I need to change the icons on the ActionBar dynamically, I have a pause and a play button and I need to replace the play button with the pause button as the user click on it. I have searched and I found it:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if(DEBUG) Log.i("onCreateOptionsMenu()", "onCreateOptionsMenu() -> LogicAnalizerView");
//menu.add("").setIcon(R.drawable.pause).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.actionbarlogic, menu);
menu.removeItem(R.id.pauseLogic);
return true;
}
So in this way I remove the Pause button and I can add it too, but it only happen when I start the Activity and the ActionBar is drawn. How can I force to redraw the ActionBar? Also, on this way the whole ActionBar is redrawn. Is that right? Is any way to redraw only the button/icon I want?
Thank you :)