Saturday, 17 August 2013

Change Android Action Bar Menu Item's Icon on Click

Change Android Action Bar Menu Item's Icon on Click

I'm using sherlock action bar. I have 2 items on the action bar. When the
item is chosen (active), I want to change the icon's image.
This is my code on Java
@Override
public boolean onPrepareOptionsMenu (Menu menu){
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.menutes, menu);
todaySched=menu.findItem(R.id.todaySched);
if(todaySched.isEnabled()){
todaySched.setIcon(R.drawable.calendarselected);
}
return true;
}
but when I do this the icon become double, and the icon won't change
neither. Can someone help?

No comments:

Post a Comment