ActionBarSherlock icon indicating copy to clipboard operation
ActionBarSherlock copied to clipboard

MenuVisibilityListener not firing in compatibility mode.

Open dhaag opened this issue 11 years ago • 2 comments

When I add a menu visibility listener to the action bar, the listener only fires when showing a real action bar, and not the compatible one. I reproduced this on a Galaxy Nexus 4.2.2 where the onMenuVisibilityChanged() listener is called and on a Motorola Atrix 2.3.6, where the onMenuVisibilityChanged() listener is NOT called.

A fix for this which seems to work is to add the following code to ActionBarSherlockCompat.java

@Override
public boolean onOpenSubMenu(MenuBuilder subMenu) {
    aActionBar.dispatchMenuVisibilityChanged(true);     // ### Newly added ### 
    return true;
}

@Override
public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
    aActionBar.dispatchMenuVisibilityChanged(false);     // ### Newly added ### 
    checkCloseActionMenu(menu);
}

I've only had minimal time looking at the ActionBarSherlock code, so I'm not all that confident this is the best way to fix this.

dhaag avatar Mar 01 '13 04:03 dhaag

Did you called addOnMenuVisibilityListener methods with OnMenuVisibilityListener parameters? There is also removeOnMenuVisibilityListener too

iNoles avatar Mar 01 '13 07:03 iNoles

Well, sure I added the listener OnMenuVisibilityListener. That's how I figured out it was working on a new JB device, but then not on the older GB device.

dhaag avatar Mar 01 '13 18:03 dhaag