In my android activity, i removed the Action Bar by using this Theme

 <style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>

but my problem is “onCreateOptionsMenu” is not display, I tried this method to create that pls see

 private void getOverflowMenu()
    {

        try
            {
                ViewConfiguration config = ViewConfiguration.get(Home.this);
                Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
                if (menuKeyField != null)
                    {
                        menuKeyField.setAccessible(true);
                        menuKeyField.setBoolean(config , false);
                    }
            } catch (Exception e)
            {
                e.printStackTrace();
            }
    }

in this “onCreateOptionsMenu” is not displaying. please help me

but it displaying in Samsung

Because: in Samsung mobile has its own hardware menu button, but not in nexus etc

please see the image

enter image description here

有帮助吗?

解决方案

finally i got the answer

in my AndroidManifest.xml i just removed this line

   android:targetSdkVersion="18" 

其他提示

If you don't have action bar and neither a menu button (on most devices) where do you want to display your menu??

The easiest way is to use PopupMenu. Add a button somewhere in your layout and on the click even add the PopupMenu (Dropdown menu). If you want to use it for devices starting Android 2.1 use a Support Library.

You have HERE the android documentation about PopupMenu.

From SDK Manager you can download and see the support library v7 sample which includes PopupMenuHelper.

Hope it helps. Good Luck!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top