Java Android菜单在错误的地方膨胀
这是我目前的问题: 我的设置菜单充气不正确。我不知道为什么,这让我快发疯了!有人知道发生了什么事吗?菜单的位置应略低于溢出图标。这可能是我布局选项卡或浏览页面的方式,还是其他方式?我相信这不是一个孤立的案例,所以如果有人以前见过这个问题 提前谢谢Java Android菜单在错误的地方膨胀,java,android,xml,menu,menuitem,Java,Android,Xml,Menu,Menuitem,这是我目前的问题: 我的设置菜单充气不正确。我不知道为什么,这让我快发疯了!有人知道发生了什么事吗?菜单的位置应略低于溢出图标。这可能是我布局选项卡或浏览页面的方式,还是其他方式?我相信这不是一个孤立的案例,所以如果有人以前见过这个问题 提前谢谢 在我的主要活动中: @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action b
在我的主要活动中:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
在我的菜单_main.xml中:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"
android:id="@+id/menu_item">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="101"
app:showAsAction="never" />
<item
android:id="@+id/action_about"
android:title="@string/action_about"
android:orderInCategory="102"
app:showAsAction="never"/>
</menu>
这是默认的UI模式,没有错误,请参阅以下屏幕截图: 不过,如果你不喜欢,你可以改变这种行为 有关详细信息,请参阅