openOptionsMenu() across android versions

我是研究僧i 提交于 2019-12-23 02:43:33

问题


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;
        }

     }
  };

回答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.



来源:https://stackoverflow.com/questions/11764854/openoptionsmenu-across-android-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!