Here's the class (basically) I use to safely call invalidateOptionsMenu() on Honeycomb or pre-Honeycomb:
public class SDKLevel11TabletBridge { private static SDKLevel11TabletInterface intf; private static boolean intfLoaded; private interface SDKLevel11TabletInterface { void invalidateOptionsMenu(Activity activity); } private static class SDKLevel11TabletInterfaceImpl implements SDKLevel11TabletInterface { @Override public void invalidateOptionsMenu(Activity activity) { activity.invalidateOptionsMenu(); } } private SDKLevel11TabletBridge() { // Nothing to do } static { intfLoaded = false; } private static void ensureInterface() { if (!intfLoaded) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) intf = new SDKLevel11TabletInterfaceImpl(); intfLoaded = true; } } public static void invalidateOptionsMenu(Activity activity) { ensureInterface(activity); if (intf != null) intf.invalidateOptionsMenu(activity); } } I am saying basically, because I am also checking that it is actually a tablet by putting a bool resource into the values-xlarge-v11 folder. On Apr 28, 5:22 pm, Steve <rascal2...@gmail.com> wrote: > An good workaround is described in the docs, under User Interface, > Creating Menus. This will allow me to implement dynamic menus in > TabActivity. > > On Android 2.3 and lower, the system calls onPrepareOptionsMenu() each > time the user opens the Options Menu. > > On Android 3.0 and higher, you must call invalidateOptionsMenu() when > you want to update the menu, because the menu is always open. The > system will then call onPrepareOptionsMenu() so you can update the > menu items. > > Despite this, the behavior of onCreateOptionMenu on honeycomb is still > not what I expected. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en