我有夸大我的行动吧和创建的项目。这些数字表明溢出,但是当我尝试添加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"