在工具栏项目菜单中将项目与标题分组

时间:2018-10-25 07:24:26

标签: android android-studio grouping android-toolbar menuitem

我想对以下项目进行分组,这是工具栏项目菜单图片1。我想更改它,如下所示:图片2最后一个。所以我该怎么做 ?请帮我。谢谢

这是我的xml代码: `

<item
    android:id="@+id/action_search2"
    android:orderInCategory="100"
    android:icon="@drawable/ic_search"
    myapp:actionViewClass="android.widget.SearchView"
    android:title="Search"
    app:showAsAction="always"
    android:visible="false"/>

<item
    android:id="@+id/filter_city"
    android:orderInCategory="100"
    android:icon="@drawable/ic_sort_black_24dp"
    android:title="filter"
    app:showAsAction="always"
    android:visible="true">
    <menu>
        <item
            android:id="@+id/cityAll"
            android:title="SEMUA" />
        <item
            android:id="@+id/citySby"
            android:title="SURABAYA" />
        <item
            android:id="@+id/cityJkt"
            android:title="JAKARTA" />
        <item
            android:id="@+id/statusAll"
            android:title="SEMUA STATUS" />
        <item
            android:id="@+id/statusPublish"
            android:title="PUBLISH" />
        <item
            android:id="@+id/statusNotPublish"
            android:title="NOT PUBLISH" />
        <item
            android:id="@+id/statusClose"
            android:title="CLOSE" />
    </menu>
</item>

`

pic 1 pic 2

2 个答案:

答案 0 :(得分:0)

Angular CLI: 1.7.4
Node: 8.9.2
OS: darwin x64
Angular: 4.4.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, tsc-wrapped

@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.3.4
webpack: 3.11.0

答案 1 :(得分:0)

这是您的解决方案,请尝试以下代码段-

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <item
        android:id="@+id/cityAll"
        android:title="SEMUA" />
    <item
        android:id="@+id/citySby"
        android:title="SURABAYA" />
    <item
        android:id="@+id/cityJkt"
        android:title="JAKARTA" />
    <item
        android:id="@+id/statusAll"
        android:title="SEMUA STATUS" />
    <item
        android:id="@+id/statusPublish"
        android:title="PUBLISH" />
    <item
        android:id="@+id/statusNotPublish"
        android:title="NOT PUBLISH" />
    <item
        android:id="@+id/statusClose"
        android:title="CLOSE" />

</menu>

这是您的输出-

enter image description here