Reputation: 151
How can I change an Menu Item icon during run time according to an If statement ? This is the code that I have and it results in a crash.
public boolean onPrepareOptionsMenu(Menu Item) {
if (favorite == true){
itema = (MenuItem) findViewById(R.id.action_search);
itema.setIcon(R.drawable.ic_action_importants);
}
return true;
}
Upvotes: 0
Views: 326