Domanda

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>
È stato utile?

Soluzione

Add the below line into the menu xml file

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top