我试图把一个动作条有两个图标(一个要去的主要活动,而另一个会前一个)菜单栏有时会显示图标,有时不
的事情是,我有这样的XML被用作菜单:
<item android:id="@+id/Main_App"
android:title="Main"
app:showAsAction="always|withText"
android:orderInCategory="1"
android:icon="@drawable/ic_home"/>
<item android:id="@+id/back_App"
android:title="Back"
app:showAsAction="always|withText"
android:orderInCategory="2"
android:icon="@drawable/ic_back"/>
而且使用它的代码:
@覆盖
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu2, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.Main_App) {
Intent getNewMessageAct = new Intent(this,UpLinksActivity.class);
startActivity(getNewMessageAct);
finish();
return true;
} else if (id == R.id.back_App){
Intent getNewMessageAct = new Intent(this,NewMessageActivity.class);
startActivity(getNewMessageAct);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
我总是用相同的菜单,有时图标适合在动作条,有时不是。我不明白为什么会发生。
没什么做一下大小,因为它具有安装空间。
原因是什么,可以理解的任何想法。
感谢您的回答,我一直在深入探索,发现问题所在。 我也把android:showAsAction,它很奇怪,因为它给出了一个XML错误,但编译它时,它运行良好。 – 2014-10-02 11:53:27