Reputation: 1042
I want to add a function in my app that checks if a menu item is disabled or enabled, if disabled I want my app to do tasl a, if enabled I want my app to do task b.
what I have tried so far;
if (menuItem.setEnabled()==false){
//do stuff
} else {
//do stuff
}
if (menuItem.setEnabled(false)){
//do stuff
} else {
//do stuff
}
if (menuItem.setEnabled().equals(false)){
//do stuff
} else {
//do stuff
}
I am not sure how I can do this, as whatever I tried doesn't seem to work.
Upvotes: 0
Views: 527
Reputation: 16976
Try this:
MenuItem mymenu = menu.findItem(R.id.mine_menu);
And:
if(mymenu.isEnabled()){
//do something
}
Upvotes: 1