I've got the hamburger icon opening the Drawer on a page utilising a flag in Activity_ActionBarHomeClick as suggested by Erel and it works fine except that if the Drawer is open when the triple dot menu button is clicked the Drawer remains open and you don't know to close it until one of the menu items is clicked.
Is there a menu dropdown event that can be implemented so that open things can be closed when the menu is invoked?
Because it doesn't look right - at least to me. If one type of menu opens then another, if already open, should close leaving the choice of only the last to open to the user.
Sub ReCreate_Menu (Menu As Object)
If CurrentPage = B4XPages.GetPage("Page 3") Then
CallSub(CurrentPage, "CloseDrawer")
End If
End Sub
#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
processBA.raiseEvent(null, "create_menu", menu);
return true;
}
public boolean _onPrepareOptionsMenu(android.view.Menu menu) {
processBA.raiseEvent(null, "recreate_menu", menu);
return true;
}
'in B4XPage_Created
Dim ab As JavaObject = B4XPages.GetManager.ActionBar
Dim listener As Object = ab.CreateEventFromUI("android.app.ActionBar.OnMenuVisibilityListener", "MenuVisible", Null)
ab.RunMethod("addOnMenuVisibilityListener", Array(listener))
Step #2:
B4X:
Sub MenuVisible_Event (MethodName As String, Args() As Object) As Object
'hide the drawer here
Return Null
End Sub