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: 4,212
  • B4i_B4XDrawer.zip
    33.5 KB · Views: 1,673
  • B4XDrawer.b4xlib
    2.5 KB · Views: 1,920
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Last edited:

Rusty

Well-Known Member
Licensed User
Longtime 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
Longtime 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
Longtime 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
Longtime User
i use B4XDrawer ,i load Drawer.CenterPanel.LoadLayout with CustomListView
after load every thing CustomListView not response to touch or scroll ?
 

Alexander Stolte

Expert
Licensed User
Longtime User
i use B4XDrawer ,i load Drawer.CenterPanel.LoadLayout with CustomListView
after load every thing CustomListView not response to touch or scroll ?
Please make a New thread for this question, Because i use it with tabstrip and 3 Custom listviews and all works ;)
 
Status
Not open for further replies.
Top