0

I need to create menu in titlebar, where user can chose many variants at one time. It will be a filter options of content in activity.

So, it should looks like this:

enter image description here

I can use standard menu items like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/one"
        android:checkable="true"
        android:checked="true"
        android:title="@string/one"
        app:showAsAction="never" />
    <item
        android:id="@+id/two"
        android:checkable="true"
        android:checked="true"
        android:title="@string/two"
        app:showAsAction="never" />
</menu>

And it will work perfectly, but after click on any item, menu will close. I find old question about it: Android - keep options menu open . May be already there are some variants to resolve it, without create menu by my own?

Or I can use spinner:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/one"
        android:icon="@drawable/ic_arrow_dropdown"
        app:actionViewClass="android.widget.Spinner"
        app:showAsAction="always"
        android:title="some title" />
</menu>

But Spinner doesn't support multiselect. What is the right way to do it?

z17
  • 423
  • 1
  • 7
  • 17

0 Answers0