B4A Library [B4X] B4XDrawer - sliding drawer

Status
Not open for further replies.
Edit: Cross platform example based on B4XPages
b4adrawer.gif


SS-2018-10-03_17.51.11.png


A class that implements a sliding menu. Unlike the nice jfeinstein SlidingMenu library the drawer covers the activity instead of pushing it. It is similar to the various design support navigation drawer libraries.

Instructions:
1. Initialize the drawer object:
B4X:
Drawer.Initialize(Me, "Drawer", Activity, 300dip) 'Page1.RootPanel in B4i
300dip = left menu width

2. Load the "Activity layout" to the drawer:
B4X:
Drawer.CenterPanel.LoadLayout("1")
3. Load the menu layout:
B4X:
Drawer.LeftPanel.LoadLayout("Left")
4. Handle back key (B4A):
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
   If KeyCode = KeyCodes.KEYCODE_BACK And Drawer.LeftOpen Then
       Drawer.LeftOpen = False
       Return True
   End If
   Return False
End Sub

5. Handle resize (B4i):
B4X:
Private Sub Page1_Resize(Width As Int, Height As Int)
   Drawer.Resize(Width, Height)
End Sub

The attached example is based on AppCompat. However you can use it in any project you like. You can also customize its behavior. The code is not too complicated.

Updates:

- 1.55 - New StateChanged (Open As Boolean) event.
- 1.53 - Adds support for B4J (without gestures). No need to update if using with B4A or B4i.
- 1.52 - Clicks on the drawer panel are not passed to the underlying panel.
- 1.51 - GestureEnabled property.

B4XDrawer is distributed as a b4xlib. It is an internal library.
 

Attachments

  • B4A_B4XDrawer.zip
    11.4 KB · Views: 2,222
  • B4i_B4XDrawer.zip
    33.5 KB · Views: 775
  • B4XDrawer.b4xlib
    2.5 KB · Views: 729
Last edited:

DonManfred

Expert
Licensed User
Last edited:

Rusty

Well-Known Member
Licensed User
Thanks Erel, I had already downloaded and "installed" this library, but I installed it into my additional libraries not noticing it was in the Anywhere libraries (previous version). Your post made me search this out. :)
 

DonManfred

Expert
Licensed User
Thanks Erel, I had already downloaded and "installed" this library, but I installed it into my additional libraries not noticing it was in the Anywhere libraries (previous version). Your post made me search this out. :)

??????????????
 

Rusty

Well-Known Member
Licensed User
Hi Don,
When I install B4a, it creates a folder: D:\Program Files (x86)\Anywhere Software\Basic4android\Libraries
My additional libraries is in a folder: D:\Survey Projects\ANDROID LIBRARIES
Both folders had a copy of the ViewEX library, I failed to delete one and update the other with the new version.
The app was finding the OLD one...that's all.
Rusty
 

hanyelmehy

Active Member
Licensed User
i use B4XDrawer ,i load Drawer.CenterPanel.LoadLayout with CustomListView
after load every thing CustomListView not response to touch or scroll ?
 

techknight

Well-Known Member
Licensed User
What makes the hemburger menu appear blue on the iOS port? I cant seem to find and fix it.
 
Status
Not open for further replies.
Top