ActionBarSherlock
ActionBarSherlock copied to clipboard
MenuVisibilityListener not firing in compatibility mode.
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.
Did you called addOnMenuVisibilityListener methods with OnMenuVisibilityListener parameters? There is also removeOnMenuVisibilityListener too
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.