操作栏项目不显示 [英] Action Bar items not Showing

查看:153
本文介绍了操作栏项目不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有夸大我的行动吧和创建的项目。这些数字表明溢出,但是当我尝试添加code,并使其显示出与yourapp:showAsAction =ifRoom,它给我的错误。

I have inflated my action bar and created items. They show in the overflow but when I try to add code and make them show with yourapp:showAsAction="ifRoom", it gives me errors.

下面是我的main.xml:

Here is my main.xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/action_settings"/>
<item android:id="@+id/home"
      android:icon="@drawable/ic_menu_home"
      android:title="Home"
      yourapp:showAsAction="ifRoom" />
<item android:id="@+id/back"
      android:icon="@drawable/ic_menu_back"
      android:title="Back"
      yourapp:showAsAction="ifRoom"  />

</menu>

下面是我的Java code:

Here is my java code:

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return super.onCreateOptionsMenu(menu);
}

感谢你在前进!

推荐答案

变更

 yourapp:showAsAction="ifRoom"

android:showAsAction="ifRoom"

这篇关于操作栏项目不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆