jeudi 19 janvier 2017

How to prevent the ActionBar Menu from collapsing on selection?

here is my menu.xml

<menu xmlns:android="http://ift.tt/nIICcg"
xmlns:app="http://ift.tt/GEGVYd"
xmlns:tools="http://ift.tt/LrGmb4"
tools:context=".MainActivity">

<item
   android:id="@+id/filter"
    android:icon="@drawable/filter"
    app:showAsAction="always"
    android:title="Filter">

    <menu>
        <item
            android:id="@+id/action_dropdown1"
            android:title="free"
            android:checkable="true"
            app:showAsAction="always"
            android:icon="@drawable/ic_free"/>
        <item
            android:id="@+id/action_dropdown2"
            android:title="paid"
            android:icon="@drawable/ic_paid">

            <menu>
                <group android:checkableBehavior="all">

                <item
                    android:id="@+id/paid_cat1"
                    android:title="0-50"
                    android:checkable="true"
                    android:icon="@drawable/ic_paid"/>
                <item
                    android:checkable="true"
                    android:id="@+id/paid_cat2"
                    android:title="51-100"
                    android:icon="@drawable/ic_paid"/>

                <item
                    android:checkable="true"
                    android:id="@+id/paid_cat3"
                    android:title="101-500"
                    android:icon="@drawable/ic_paid"/>

                <item
                    android:checkable="true"
                    android:id="@+id/paid_cat4"
                    android:title="500-10,000"
                    android:icon="@drawable/ic_paid"/>

                <item
                    android:checkable="true"
                    android:id="@+id/paid_cat5"
                    android:title="show all"
                    android:icon="@drawable/ic_paid"/>

                </group>

            </menu>
            </item>

        <item

            android:id="@+id/action_find"
            android:title="find"
            android:icon="@drawable/ic_search_black_24dp"/>

    </menu>
    </item>

<item
    android:id="@+id/action_search"
    android:icon="@android:drawable/ic_menu_search"
    app:showAsAction="always"
    app:actionViewClass="android.support.v7.widget.SearchView"
    android:title="Search"/>

what i want to achieve is user should be able to select multiple menu items when when they click on checkbox in menu ... but i as soon as click item it disappear

or is there any better alternative to achieve the same i thought of using spinner as well but it behaves the same




Aucun commentaire:

Enregistrer un commentaire