![](/img/trans.png)
[英]Android: how to replace the three dots in the TOOLBAR menu (not the action bar)
[英]Three dots settings menu in the Action Bar Android doesn't appears
我想在操作欄上創建一個簡單的選項菜單(經典的三個點)。 我寫了這部分代碼,但是什么也沒出現:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
即使是這個,但始終沒有出現:
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, "Settings");
return super.onCreateOptionsMenu(menu);
}
動作欄上沒有三個點。 還有什么要寫的,也許在onCreate()
?
編輯。 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>
將以下行添加到菜單xml文件中
<item
android:title="Info"
android:showAsAction="never"
android:id="@+id/settings" >
</item>
檢查AndroidManifest.xml,設置android:targetSdkVersion =“ 10”或以下版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.