문제

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>
도움이 되었습니까?

해결책

Add the below line into the menu xml file

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top