gpt4 book ai didi

android - 在 Android 中创建选项菜单

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:05:07 24 4
gpt4 key购买 nike

我正在尝试像这个链接一样在android中制作一个选项菜单 http://developer.android.com/guide/topics/ui/menus.html#options-menu

但是我开发的菜单没有显示在页面底部,而是显示在顶部操作栏中。

我的 xml 在 my_options_menu.xml 下方

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/menu_addnew"
android:title="Νέο"
android:showAsAction="ifRoom"/>
<item android:id="@+id/help"
android:icon="@drawable/menu_addnew"
android:title="Βοήθεια" />
</menu>

我的java代码是

   @Override
public boolean onCreateOptionsMenu(Menu menu){

MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.my_options_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.new_game:
//newGame();
return true;
case R.id.help:
//showHelp();
return true;
default:
return super.onOptionsItemSelected(item);
}
}

如何才能在我的应用程序底部而不是顶部操作栏上显示菜单?

我的菜单如下图所示 enter image description here

我想创建如下图所示的菜单

enter image description here

如何做到这一点?有人可以帮助我吗?

最佳答案

此页面应回答您的任何问题: http://developer.android.com/guide/topics/ui/actionbar.html“使用拆分操作栏”下应该是添加菜单项所需的所有信息到页面底部

关于android - 在 Android 中创建选项菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18813367/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com