Question

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>
Était-ce utile?

La solution

Add the below line into the menu xml file

<item
   android:title="Info"
   android:showAsAction="never"
   android:id="@+id/settings" >
</item>

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top