Android 3.0 Honeycomb: How to enable/disable Menu Items in Action Bar?

Viewed 14890

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

1 Answers
Related