在android中向自定义标题栏添加菜单(溢出)

在android中向自定义标题栏添加菜单(溢出),android,android-layout,Android,Android Layout,我已在“活动”中创建了自定义标题栏 现在我想将如下图所示的菜单(溢出)添加到我的自定义标题栏中 我指的是这个。但是,这对我不起作用。我只想要有3个项目的溢出菜单 这是我的密码 Activity.java public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. M

我已在“活动”中创建了自定义标题栏

现在我想将如下图所示的菜单(溢出)添加到我的自定义标题栏中

我指的是这个。但是,这对我不起作用。我只想要有3个项目的溢出菜单

这是我的密码

Activity.java

 public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.menutit, menu);

            return super.onCreateOptionsMenu(menu);
        }
MenuTit.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- Search / will display always -->
    <item
        android:id="@+id/action_search"
        android:icon="@drawable/yellow"
        android:showAsAction="always"
        android:title="action_search"/>

    <!-- Location Found -->
    <item
        android:id="@+id/action_location_found"
        android:icon="@drawable/yellow"
        android:showAsAction="always"
        android:title="action_location_found"/>

    <!-- More -->
    <item
        android:id="@+id/a_More"
        android:icon="@drawable/yellow"
        android:showAsAction="always"
        android:title="More">
        <menu>

            <!-- Refresh -->
            <item
                android:id="@+id/action_refresh"
                android:icon="@drawable/brown"
                android:showAsAction="never"
                android:title="action_refresh"/>

            <!-- Help -->
            <item
                android:id="@+id/action_help"
                android:icon="@drawable/brown"
                android:showAsAction="never"
                android:title="action_help"/>

            <!-- Check updates -->
            <item
                android:id="@+id/action_check_updates"
                android:icon="@drawable/brown"
                android:showAsAction="never"
                android:title="action_check_updates"/>
        </menu>
    </item>

</menu>


任何人都能告诉我,在自定义标题栏中添加菜单项需要做些什么吗?

您需要在菜单xml中添加这些项,并使用showAsAction=never或ifRoom。

哪个部分不工作。。。您是否能够创建另一个(非溢出)动作项出现在动作栏中?是否使用
appcompat
sherlockactionbar
?@Fllo否我没有使用appcompat或sherlockactionbar。@es0329我只想要菜单,但它不起作用我没有使用动作栏我只想要菜单,所以我想我不需要动作栏。我这样做了,但它仍然不起作用。它没有给我任何错误,但它没有显示菜单。如果你按下菜单按钮怎么办?是否有一个选项菜单出现了其他缺少的项目?添加代码到原来的文章。菜单按钮根本不显示。我是指设备的硬件菜单按钮,它在活动底部显示设置。