简体   繁体   English

为什么不在操作栏中显示菜单项?

[英]Why don't show menu item in actionbar?

I try to show once menu item in action bar .Now all items showing into the menu.But I want once items showing out of menu in action bar . 我尝试在操作栏中显示一次菜单项。现在所有项目都显示在菜单中。但是我希望在操作栏中显示一次菜单项。

<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="com.example.nabege.Show_subject_Activity" >

    <item
        android:id="@+id/about_us"
        android:title="@string/about_us"/>
    <item
        android:id="@+id/help"
        android:title="@string/help"/>
    <item
        android:id="@+id/setting"
        android:title="@string/setting"/>
    <item
        android:id="@+id/collectionName"
        android:title=""
        app:showAsAction="always"/>

</menu>

In this case I set the title of item via programing. 在这种情况下,我将通过编程设置项目的标题。 I want my menu like this image: 我希望菜单如下图所示: 在此处输入图片说明

I change this line and solved : 我更改此行并解决:

 <item
        android:id="@+id/collectionName"
        android:title=""
        showAsAction="always"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM