安卓:菜单操作栏 [英] Android: menu in action bar
本文介绍了安卓:菜单操作栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题,把菜单中有,在右上角:
i have problem putting the menu there, in the upper right corner:
Android清单:
android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.mio.app"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light">
<activity android:name=".Lista_preventivi"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Java的:
public class Lista_preventivi extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.lista_preventivi);
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
}
菜单的xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_settings"
android:showAsAction="ifRoom"
android:title="@string/action_settings" />
</menu>
所有的作品,但菜单才会出现,如果我点击我的手机上的物理按键,它出现在像一个正常的菜单的底部。
all works, but the menu appear only if i click the physical button on my phone, and it appear at the bottom like a normal menu.
浩我可以在右上角操作栏中的图标菜单,显示菜单呢?
ho can i have the icon menu in the upper right action bar, and show the menu there?
谢谢!
推荐答案
,你的申请到应用程序的主题是安卓主题=@安卓风格/ Theme.Light。它不具有一个动作条
The theme which your are applying to the application is android:theme="@android:style/Theme.Light". it doesn't have an actionbar.
改变它的东西其中有一个操作栏一样,
Change it to something which has an action bar like,
- Theme.Sherlock.Light(需加ABS库)
- Theme.Holo.Light
在code是蛮好的。
这篇关于安卓:菜单操作栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文