B4XDrawer v1.53 adds support for B4J. This is a good opportunity to create a B4XPages example using B4XDrawer.
It does require some configuration so pay attention.
The example is based on the three pages example: https://www.b4x.com/android/forum/t...k-for-managing-multiple-pages.118901/#content
A drawer is added to the second page. Everything is implemented in the attached example.
In the page where you want to add the drawer:
Add to B4XPage_Created:
And add these subs:
It does require some configuration so pay attention.
The example is based on the three pages example: https://www.b4x.com/android/forum/t...k-for-managing-multiple-pages.118901/#content
A drawer is added to the second page. Everything is implemented in the attached example.
In the page where you want to add the drawer:
Add to B4XPage_Created:
B4X:
HamburgerIcon = xui.LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True) 'global B4XBitmap
#if B4i
Dim bb As BarButton
bb.InitializeBitmap(HamburgerIcon, "hamburger")
B4XPages.GetNativeParent(Me).TopLeftButtons = Array(bb)
#Else If B4J
Dim iv As ImageView
iv.Initialize("imgHamburger")
iv.SetImage(HamburgerIcon)
Drawer.CenterPanel.AddView(iv, 2dip, 2dip, 32dip, 32dip)
iv.PickOnBounds = True
#end if
And add these subs:
B4X:
#if B4J
Sub imgHamburger_MouseClicked (EventData As MouseEvent)
Drawer.LeftOpen = True
End Sub
#else if B4i
Private Sub B4XPage_MenuClick (Tag As String)
If Tag = "hamburger" Then
Drawer.LeftOpen = Not(Drawer.LeftOpen)
End If
End Sub
#end if
Private Sub B4XPage_CloseRequest As ResumableSub
#if B4A
'home button
If Main.ActionBarHomeClicked Then
Drawer.LeftOpen = Not(Drawer.LeftOpen)
Return False
End If
'back key
If Drawer.LeftOpen Then
Drawer.LeftOpen = False
Return False
End If
#end if
Return True
End Sub
Private Sub B4XPage_Appear
#if B4A
Sleep(0)
B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
Dim bd As BitmapDrawable
bd.Initialize(HamburgerIcon)
B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))
#End If
End Sub
Private Sub B4XPage_Disappear
#if B4A
B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(0))
#end if
End Sub
Private Sub B4XPage_Resize (Width As Int, Height As Int)
Drawer.Resize(Width, Height)
End Sub
Attachments
Last edited: