Actionbar's overflow menu open/close listener

Dima Kornilov

I want to listen when user opens/closes the overflow menu (three dots) of ActionBar, someway like this:

void onOverflowMenu(boolean expanded) {
}

To handle open cases, I've tried onPrepareOptionsMenu(), but it's triggered when ActionBar is constructed or when invalidateOptionsMenu() is called. This is not what I want.

I was able to detect overflow menu is closed if user selects a menu item in onMenuItemSelected(). But I also want to detect it if user closes overflow menu by tapping outside of it, by pressing back key, and all other cases.

Is there a way to implement that?

schabluk

To catch open action in the Activity:

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    ...
    return super.onMenuOpened(featureId, menu);
}

To catch closed action, also if user touch outside of Menu view:

@Override
public void onPanelClosed(int featureId, Menu menu) {
    ...
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Custom actionbar layout with overflow menu

From Dev

how to change actionbar's menu item text color in material design

From Dev

How to add click's listener for app's icon on ActionBar in Android?

From Dev

ActionBar items appear always in Overflow Menu

From Dev

The menu item isn't showing in the ActionBar, only in overflow menu

From Dev

MonkeyTalk (2.0.4) Android (KitKat) - ActionBar overflow menu support?

From Dev

Testing a Fragment's menu items that should appear in the ActionBar

From Dev

Detect click on Actionbar's Overflow menu button

From Dev

AppCompat overflow menu overlapping actionbar

From Dev

Android overflow menu positioned above actionbar/toolbar?

From Dev

Android ActionBar overflow menu style

From Dev

Why is my overflow dropdown menu on top of the actionbar?

From Dev

Actionbar items always appear in overflow menu

From Dev

Actionbar is showing menu icons as overflow and not individual icons

From Dev

How to Make a Menu Like Stack Overflow's

From Dev

Action buttons move to overflow menu (ActionBar)

From Dev

How to style android actionbar overflow menu

From Dev

Items getting added to "overflow menu" instead of the ActionBar

From Dev

Android ActionBar overflow menu options not working when fragment visible

From Dev

ActionBar overflow menu with three dots is not showing

From Dev

Check ActionBar's overflow popup is showing

From Dev

Actionbar's overflow menu open/close listener

From Dev

MonkeyTalk (2.0.4) Android (KitKat) - ActionBar overflow menu support?

From Dev

Custom ActionBar Overflow Menu

From Dev

Adding overflow menu in actionbar android

From Dev

Why my options menu changes to ActionBar overflow menu unexpectedly?

From Dev

Overflow menu is not showing in Actionbar

From Dev

How to style android actionbar overflow menu

From Dev

actionbar overflow menu items icons padding

Related Related

  1. 1

    Custom actionbar layout with overflow menu

  2. 2

    how to change actionbar's menu item text color in material design

  3. 3

    How to add click's listener for app's icon on ActionBar in Android?

  4. 4

    ActionBar items appear always in Overflow Menu

  5. 5

    The menu item isn't showing in the ActionBar, only in overflow menu

  6. 6

    MonkeyTalk (2.0.4) Android (KitKat) - ActionBar overflow menu support?

  7. 7

    Testing a Fragment's menu items that should appear in the ActionBar

  8. 8

    Detect click on Actionbar's Overflow menu button

  9. 9

    AppCompat overflow menu overlapping actionbar

  10. 10

    Android overflow menu positioned above actionbar/toolbar?

  11. 11

    Android ActionBar overflow menu style

  12. 12

    Why is my overflow dropdown menu on top of the actionbar?

  13. 13

    Actionbar items always appear in overflow menu

  14. 14

    Actionbar is showing menu icons as overflow and not individual icons

  15. 15

    How to Make a Menu Like Stack Overflow's

  16. 16

    Action buttons move to overflow menu (ActionBar)

  17. 17

    How to style android actionbar overflow menu

  18. 18

    Items getting added to "overflow menu" instead of the ActionBar

  19. 19

    Android ActionBar overflow menu options not working when fragment visible

  20. 20

    ActionBar overflow menu with three dots is not showing

  21. 21

    Check ActionBar's overflow popup is showing

  22. 22

    Actionbar's overflow menu open/close listener

  23. 23

    MonkeyTalk (2.0.4) Android (KitKat) - ActionBar overflow menu support?

  24. 24

    Custom ActionBar Overflow Menu

  25. 25

    Adding overflow menu in actionbar android

  26. 26

    Why my options menu changes to ActionBar overflow menu unexpectedly?

  27. 27

    Overflow menu is not showing in Actionbar

  28. 28

    How to style android actionbar overflow menu

  29. 29

    actionbar overflow menu items icons padding

HotTag

Archive