Action Bar items not Showing

徘徊边缘 提交于 2019-12-12 01:43:58

问题


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.

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>

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);
}

Thank you in advance!


回答1:


change

 yourapp:showAsAction="ifRoom"

to

android:showAsAction="ifRoom"


来源:https://stackoverflow.com/questions/23772602/action-bar-items-not-showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!