创建于Android的一个选项菜单 [英] Creating an Options Menu in Android

查看:212
本文介绍了创建于Android的一个选项菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个选项菜单的Andr​​oid这样的链接
http://developer.android.com/guide/topics/ui /menus.html#options-menu

I'm trying to make an option menu in android like this link http://developer.android.com/guide/topics/ui/menus.html#options-menu

但我的开发菜单显示不在我的页面底部,但在顶部的行动吧。

but my developed menu shows not on bottom of my page but in top action bar.

我的XML是波纹管my_options_menu.xml

my xml is bellow 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 code是

and my java code is

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

我能做些什么,以显示在我的应用程序的底部,而不是顶部操作栏菜单?

What can I do to show the menu on bottom of my application and not on top action bar?

我的菜单showes在下面的图片

My menu showes in below image

我要像下面的图片创建菜单

I want create menu like below image

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

How can do that? Can someone help me?

推荐答案

这是在操作菜单中显示的原因是因为你有的android:showAsAction =ifRoom
在XML文件中。除去这一点,你应该是好的。

The reason this is showing in the action menu is because you have android:showAsAction="ifRoom" in your xml file. remove that and you should be good.

这篇关于创建于Android的一个选项菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆