2

I want to create a simple option menù on the Action Bar (classic three dots). I wrote this part of code but nothing appear:

   @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }

Even this one but always nothing appear:

    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(0, 0, 0, "Settings");
        return super.onCreateOptionsMenu(menu);
    }

There are no three dots on the Action Bar. Is there anything else to write maybe in the onCreate()?

Edit. The menu.xml

<xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Info" android:id="@+id/settings"></item>
</menu>
David_D
  • 1,404
  • 4
  • 31
  • 65

2 Answers2

3

Add the below line into the menu xml file

<item
   android:title="Info"
   android:showAsAction="never"
   android:id="@+id/settings" >
</item>
  • this is no use. for newer android 3.0+, it show menus in actionbar instead of show three dot menu. more info refer this post: http://stackoverflow.com/questions/15250024/show-options-menu-button-on-galaxy-nexus-android-4-1 – crifan Apr 11 '14 at 05:23
-4

check AndroidManifest.xml, set android:targetSdkVersion="10" or lowwer.

lynn8570
  • 1,685
  • 1
  • 14
  • 24