Rafał
Rafał

Reputation: 602

Popup Dialog as Menu when Menu is clicked

I want to implement Dialog where I will be able to set values. Something like this

I also would want to Dialog will Popup when I click on three dots (Menu) on Toolbar. I've got toolbar like this

So far I've got menu

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


<item
    android:id="@+id/menu_allclients_min_date"
    android:orderInCategory="200"
    android:title="@string/menu_min_date"
    app:showAsAction="never" />

<item
    android:id="@+id/menu_allclients_max_date"
    android:orderInCategory="201"
    android:title="@string/menu_max_date"
    app:showAsAction="never" />

<item
    android:id="@+id/menu_allclients_min_amount"
    android:orderInCategory="202"
    android:title="@string/menu_min_amount"
    app:showAsAction="never" />

<item
    android:id="@+id/menu_allclients_max_amount"
    android:orderInCategory="203"
    android:title="@string/menu_max_amount"
    app:showAsAction="never" />

Now, when Menu is clicked it show as list of four items. But It isn't a way I want to implement it.

I would also know is there any listener when Menu icon( three dots ) is clicked. It would solve my problem.

Upvotes: 0

Views: 428

Answers (1)

Bruno Ferreira
Bruno Ferreira

Reputation: 1571

For help i sugest, if you dont have more than 2 menu itens, make a menu item set the 3 dots as icon and always as showasaction. After that in on menu item selected in your activity make a switch to check item selected and if is the 3 dots item make the dialog.

Upvotes: 1

Related Questions