it’s pretty easy to disable a menu item in XML:
<item android:id="@+id/men_1"
android:title="@string/men_1"
android:showAsAction="ifRoom|withText"
android:icon="@drawable/ic_menu_1"
android:enabled="false"/>
It’s also pretty easy to change it via code on a <3.0 app:
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
super.onPrepareOptionsMenu(menu);
MenuItem item = menu.findItem(R.id.men_1);
item.setEnabled(false);
return true;
}
But how would I do it on Android 3.x?
I want to disable menu options depending on the Fragment shown.
Kind regards,
jellyfish
Pretty much the same but put code into the fragment instead, note different method signature.
So the fragment takes responsibility for inflating the menu etc.
Edit Note the need to call
setHasOptionsMenu(true)