1

I have an app that's been designed with the titlebar hidden in all intents. I want to utilize Activity.openOptionsMenu() from a button. It works fine on 2.2 but when I run the app on honeycomb, calling openOptionsMenu() doesn't seem to work. Is there another way?

onclick code here, if it matters. This is inside my mapview activity, extending MapView:

  OnClickListener ocl =  new OnClickListener()
  {

     @Override
     public void onClick (View v)
     {
        switch (v.getId ())
        {
           case R.id.b_options:
                                  Log.d (TAG, "options clicked");
                                  mymapview.this.openOptionsMenu ();
           break;

           case R.id.b_prev:
                                  Log.d (TAG, "prev clicked");
           break;
        }

     }
  };
Tushar
  • 8,019
  • 31
  • 38
wufoo
  • 13,571
  • 12
  • 53
  • 78
  • We've found that openOptionsMenu works fine on some devices (galaxy nexus, nexus s, emulator) but does nothing on others. It's very lame. – cidermonkey Aug 20 '12 at 19:22
  • I found the final working solution here: http://stackoverflow.com/a/17903128/784982 – Lisitso Sep 14 '13 at 10:12

1 Answers1

1

Do you have an ActionBar in your application? I believe openOptionsMenu() only works with an accompanying ActionBar in Honeycomb. ICS doesn't bring back the menu button, but you no longer need an ActionBar for openOptionsMenu() to work.

Tushar
  • 8,019
  • 31
  • 38
  • If I add ActionBar for honeycomb, will it still run on Android 2.2? Seems unlikely. – wufoo Aug 01 '12 at 18:02
  • No, it won't by default. You'll need to use something like [ActionBarSherlock](http://actionbarsherlock.com/). – Tushar Aug 01 '12 at 18:04
  • Very odd. Today openOptionsMenu() is mysteriously working as I expected. The only thing I can attribute it to is a reboot of the tablet. – wufoo Aug 02 '12 at 20:27