如何在操作栏中显示图标,这是我的代码,
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/search_icon"
android:icon="@drawable/ic_action_search"
android:showAsAction="always"
android:orderInCategory="0"
android:title="Search" >
</item>
</menu>
和
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater mif = getMenuInflater();
mif.inflate(R.menu.custom_action_bar,menu);
return super.onCreateOptionsMenu(menu);
}
感谢您的帮助!
答案 0 :(得分:2)
如果使用app compat使用app:showAsAction
<item android:id="@+id/search_icon"
android:icon="@drawable/ic_action_search"
app:showAsAction="always"
android:orderInCategory="100"
android:title="Search" >
</item>
答案 1 :(得分:0)
在Manifest.xml文件中
<activity android:name="your activity name"
android:theme="@style/Theme.Holo.Light"></activity>