我已阅读这里相当多的条目,并Android的文件在此:http://developer.android.com/guide/topics/ui/actionbar.html缺少操作栏动作图标
我创建了一个新的应用程序从Android Studio中,设定的最低SDK(21)和目标SDK( 22)到Android 5(我不需要向后兼容性)。
这是我menu.xml文件:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/undo"
android:icon="@drawable/undo"
android:title="@string/undo"
app:showAsAction="always"
/>
<item android:id="@+id/clear"
android:title="@string/clear"/>
...
</menu>
这是我相当简单的onCreate:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
paintView = (PaintView) findViewById(R.id.view);
client = new GoogleApiClient.Builder(this).addApi(Wearable.API).build();
}
我曾经尝试都总是和ifRoom,并确保撤消绘制,每完成DPI,但撤消按钮拒绝出现(在Nexus 4上测试,它有足够的空间用于至少几个图标......)!
我目前的解决方案是使用一个带有imageButton和onClick的customView(这个工作),但我想知道可能是什么问题。
看到这个链接http://stackoverflow.com/questions/31356805/options-menu-action-bar/31356900#31356900 –
谢谢。我使用android:showAsAction =“always”,它被标记为错误,正如建议使用app:showAsAction和xmlns:app =“http://schemas.android.com/apk/res-auto”命名空间。 –