Change icons in ActionBar dynamically

You’ll have to save off a reference to the MenuItem after doing the inflation. So something like the following:

public boolean onCreateOptionsMenu( Menu menu ) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(, menu );
    playMenu = menu.findItem(;
    return menu;

public void updatePlayStatus() {
    if( playService.isConnected() ) {
        playService.isPlaying() ? playMenu.setIcon(R.drawable.pause) : playMenu.setIcon(;

Then you can refer to the playMenu anytime. So you can modify the item as say your player finishes playing and should go back to a play icon.

Leave a Comment