Android Question [B4X] B4XPages menu dropdown event?

agraham

Expert
Licensed User
Longtime User
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?
 
Found it myself :)
B4X: Copy
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;   
}
 
Upvote 0
Ok. Ok.

Step #1:
Code: Copy
'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:
Code: Copy
Sub MenuVisible_Event (MethodName As String, Args() As Object) As Object
    'hide the drawer here
    Return Null
End Sub
 
Upvote 0
Back
Top