B4A Library [Class] SlidingSidebar

Hello,

With this class, you can put an hidden sidebar on one of the four sides of the screen and reveal it when needed. It can open with a button, like in the Facebook app, with a handle, as the standard Android slidingdrawer, or with a swipe gesture, like in Prixing. Many options are available to suit all needs.

List of functions:
Initialize(Parent As Panel, SidebarSize As Int, SidebarPosition As Byte, AnimType As Byte, OpenDuration As Int, CloseDuration As Int)
SetOnChangeListeners(Module As Object, SubOnFullyOpen As String, SubOnFullyClosed As String, SubOnMove As String)
Sidebar() As Panel
ContentPanel() As Panel
SetInterpolator(Value As Float)
OpenSidebar()
CloseSidebar()
IsSidebarVisible()
As Boolean
SetOpenCloseButton(Btn As View)
AddOpenCloseHandle(Hdl As View, Position As Int, Width As Int, Height As Int, FinalMovement As Byte)
EnableSwipeGesture(Enabled As Boolean, GestureAreaSize As Int, FinalMovement As Byte)
LoadDrawable(Name As String) As Object

Since September 3rd 2014, the SlidingSidebar class is completely free.

img1.png img2.png img3.png

v1.1: Fixed three bugs and optimized the animation function
 

Attachments

  • SlidingSidebar v1.1 Dw.zip
    38.1 KB · Views: 1,863
Last edited:

Informatix

Expert
Licensed User
Longtime User
1. can I change the background and how can I do that.
you use
B4X:
PanelWithSidebar.Sidebar.Background = PanelWithSidebar.LoadDrawable("popup_inline_error")
to load an internal drawing, Correct? I would like to create one that look like the one on my android 4.0 themes.

"popup_inline_error" is a system drawable. If you use ICS, the drawable provided with ICS is used (in this case, it is not different from the Gingerbread one). To select another system drawable, change the drawable name. You can also create and load your own drawable, as you do with any background.

2. When I make a "Long Press" the app shuts down
This is what the log says:
B4X:
java.lang.RuntimeException: MotionEvent { action=ACTION_UP, id[0]=0, x[0]=149.75476, y[0]=419.92093, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=820900520, downTime=820897820, deviceId=6, source=0x1002 } recycled twice![/QUOTE]

Did you download the latest version of the class ?
 

susu

Well-Known Member
Licensed User
Longtime User
I want to mix your SlidingDrawer and SlidingMenu to make a top center button that can drag down or click on it to slide down a menu. I'm confused about PanelWithSidebar.SetOpenCloseButton and PanelWithSidebar.AddOpenCloseHandle, which one I need to use or I need to use both?
 

Informatix

Expert
Licensed User
Longtime User
I want to mix your SlidingDrawer and SlidingMenu to make a top center button that can drag down or click on it to slide down a menu. I'm confused about PanelWithSidebar.SetOpenCloseButton and PanelWithSidebar.AddOpenCloseHandle, which one I need to use or I need to use both?

Since the class consumes the touch event for the handle, you cannot catch the click event. You have to modify the class. Replace "return true" at line #557 by "return false" and add a click event to your handle. In the SlidingDrawer demo, that means two changes:
- ivHandle.Initialize("") becomes ivHandle.Initialize("MyButton")
- an event handler is added:
B4X:
Sub MyButton_Click
   If Not(PanelWithSidebar.IsSidebarVisible) Then
      PanelWithSidebar.OpenSidebar
   End If
End Sub
 

susu

Well-Known Member
Licensed User
Longtime User
It works perfectly. Thank you so much :D

I add two lines to auto slide up the sidebar when click on button.
Sub MyButton_Click
If Not(PanelWithSidebar.IsSidebarVisible) Then
PanelWithSidebar.OpenSidebar
Else
PanelWithSidebar.CloseSidebar
End If
End Sub
 

worm

Member
Licensed User
Longtime User
Really nice Class :sign0142:

I've just a question: it is possible to add two SlidingSidebars (ex: one left and one right)?

ps: donation on the way :sign0188:
 

Informatix

Expert
Licensed User
Longtime User
Really nice Class :sign0142:

I've just a question: it is possible to add two SlidingSidebars (ex: one left and one right)?

ps: donation on the way :sign0188:

Thank you for your donation.

The class is not designed to accept two sidebars, but maybe you can achieve this by adding a second sidebar into the first (each sliding group is a group of two panels). Never tried.
 

metrick

Active Member
Licensed User
Longtime User
Informatix:
How can I clear the sidebar(lvMenu list) before update with new lvMenu list? I have tried lvMenu.Clear and lvMenu.Invalidate did not clear previous list contents.
Thanks.
 

metrick

Active Member
Licensed User
Longtime User
lvmenu.clear is good. It was my code.
Just donated 5. Thanks for your great contribution to b4a.
 

metrick

Active Member
Licensed User
Longtime User
Informatix:
Is there an easy way to move the lvmenu list down 10% or more from the top and still be able press buttons on left-top edge. Currently seem like the left side of the screen is for slidebar touch areas, and any things within the slidebar touch areas is disable for touch event.
 
Last edited:

JTmartins

Active Member
Licensed User
Longtime User
A little help needed

Hello,

I've been playing with this superb class and done a few changes in the layout, but there is one thing I still haven't figured out in the case of the sliding list menu (the one with 3 dots that shows the list view)

But, can we control the dimensions of the system drawable that shows the list ? How ?

I had other questions here, but I managed to solved them, so I Edited the post, and left only this question.

All help will be appreciated.

Many thanks

josé
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Hello,

I've been playing with this superb class and done a few changes in the layout, but there is one thing I still haven't figured out in the case of the sliding list menu (the one with 3 dots that shows the list view)

But, can we control the dimensions of the system drawable that shows the list ? How ?

I had other questions here, but I managed to solved them, so I Edited the post, and left only this question.

The size of any drawable is defined by the background size. If you set the background of a 50x60 panel with the drawable, the drawable will be sized 50x60.
 
Last edited:

JTmartins

Active Member
Licensed User
Longtime User
Thanks

Newbie here...

But improving everyday thanks to all community.

Thanks

José
 
Top