jfeinstein10 SlidingMenu library

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime User
The open source project is no longer maintained and there are compatibility issues with newer versions of Android. It is recommended to use B4XDrawer instead.

This is a wrapper for jfeinstein10 SlidingMenu open source project. This is a popular implementation of sliding menus. Note that you can add any layout you like in each of the side menus.

upload_2014-1-7_16-43-16.png


upload_2014-1-7_16-43-2.png


It requires B4A v6+

Example code:
B4X:
Sub Process_Globals
End Sub

Sub Globals
   Dim sm As SlidingMenu
End Sub

Sub Activity_Create(FirstTime As Boolean)
   sm.Initialize("sm")
   Dim offset As Int = 100dip
   sm.BehindOffset = offset
   sm.Mode = sm.BOTH
   Dim lv1 As ListView
   lv1.Initialize("lv1")
   For i = 1 To 10
     lv1.AddSingleLine("Action "  & i)
   Next
   sm.SecondaryMenu.AddView(lv1, 0, 0, 100%x - offset, 100%y)
   Dim b1, b2 As Button
   b1.Initialize("b1")
   b2.Initialize("b2")
   b1.Text = "Button1"
   b2.Text = "Button2"
   sm.Menu.AddView(b1, 10dip, 10dip, 100%x - offset - 20dip, 50dip)
   sm.Menu.AddView(b2, 10dip, 60dip, 100%x - offset - 20dip, 50dip)
End Sub
Sub lv1_ItemClick (Position As Int, Value As Object)
   Log(Value)
   sm.HideMenus
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
   If KeyCode = KeyCodes.KEYCODE_BACK AND sm.Visible Then
     sm.HideMenus
     Return True
   End If
   Return False
End Sub
Sub B1_Click
   Log("b1_click")
   sm.HideMenus
End Sub
Sub B2_Click
   Log("b2 click")
   sm.HideMenus
End Sub
 

Attachments

  • SlidingMenuWrapper.zip
    47.6 KB · Views: 6,205
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Hi all,
From my picture,How to match correct folder in using #AdditionalRes module attribute to reference this project res folder and package? Is right?

B4X:
#AdditionalRes: #AdditionalRes: C:\Users\ธีระ\Desktop\New Folder (2)\SlidingMenu-master\library\src\com\jeremyfeinstein\slidingmenu\lib , com.jeremyfeinstein.slidingmenu.lib, com.jeremyfeinstein.slidingmenu.lib
 

Attachments

  • HowtoRefer.png
    HowtoRefer.png
    83.7 KB · Views: 2,311

M6SOFT

Member
Licensed User
Longtime User
Hi,
When I add second #AdditionalRes (google-play-services_lib\res, com.google.android.gms) in the demo program at first post i have an error when try to compile:

B4X:
SlidingMenu\library\res\values\ids.xml:3: error: Resource at selected_view appears in overlay but not in the base package; use <add-resource> to add.

Is there any solution to mix google maps and jfeinstein10 SlidingMenu library?

Best Regards
greg
 

M6SOFT

Member
Licensed User
Longtime User
Hi Erel,
Thanks for reply.
After copy res folders i have 2 identical with duplicated all files. Then it cause:
Generating R file. Error
C:\android\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res\values\ads_attrs.xml:10: error: Attribute "adSize" has already been defined
C:\android\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res\values\ads_attrs.xml:13: error: Attribute "adUnitId" has already been defined
C:\android\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res\values\attrs.xml:20: error: Attribute "mode" has already been defined
.....
I will be waiting for new version.
Thanks
greg
 

tchart

Well-Known Member
Licensed User
Longtime User
Erel, I downloaded the Sliding Menu Demo from the Play Store (ie http://bit.ly/TWejze). One of the demo menus has options to change the look and feel of the sliding menus (shadow, transition effect etc). However I cant see these properties in the wrapper. Are they not implemented yet?
 

Roger C

Active Member
Licensed User
Longtime User
I don't get it, which folder should I refer to in the Project Attributes?
In the file from GitHub there's a library-folder with an almost empty folder named '\res', it contains two folder and nothing else...

The pic shows how the files look like in Windows Explorer.

And this is what I refer to:
B4X:
#Region  Project Attributes
    #ApplicationLabel: Dagbok
    #VersionCode: 241
    #VersionName: 2.4.1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: True
    #AdditionalRes: C:\AndroidApps\DagbokVit\SlidingMenu\library\res, com.jeremyfeinstein.slidingmenu.lib
#End Region

Still it complains that it's an unreferenced library and the code is red...
What files should be in the 'res'-folder? even if I point it to the \example\res folder, nothing happens...
 

Attachments

  • SlidingMenu Explorer.jpg
    SlidingMenu Explorer.jpg
    33.4 KB · Views: 1,597

Roger C

Active Member
Licensed User
Longtime User
Haha, yes of course. In bed last night I came up with that too. :) I was so focused about adding the resource. First timer...
Works like a charm, very nice. :)
 

Douglas Farias

Expert
Licensed User
Longtime User
@Erel
its possible make easy move like
http://www.b4x.com/android/forum/threads/actionbar-sliding-pages-tutorial.36865/
?

you tutorial of sliding pages is easy to move the finger to change the page.
i want to use this lib to make slide menu but this lib its hard to move finger i think it is 0.50%x *-*
can i change the position where you put the finger to call the slide menu?

for example 10%x *-* this is good and easy to move
 

Douglas Farias

Expert
Licensed User
Longtime User
Try this:
Code:
Dim jo As JavaObject = SlidingMenu1
jo.RunMethod("setTouchmodeMarginThreshold", Array(50%x))

this works fine 40000% best *-*

here is the code if help someone
B4X:
#Region  Project Attributes
  #ApplicationLabel: B4A Example
  #VersionCode: 1
  #VersionName:
  'SupportedOrientations possible values: unspecified, landscape or portrait.
  #SupportedOrientations: unspecified
  #CanInstallToExternalStorage: False
  #AdditionalRes: C:\Users\Douglas\Documents\SlidingMenu-master\library\res, com.jeremyfeinstein.slidingmenu.lib
#End Region

#Region  Activity Attributes
  #FullScreen: False
  #IncludeTitle: True
#End Region

Sub Process_Globals
End Sub

Sub Globals
  Dim sm As SlidingMenu
End Sub

Sub Activity_Create(FirstTime As Boolean)
  sm.Initialize("sm")
  Dim offset As Int = 200dip
  sm.BehindOffset = offset
  sm.Mode = sm.LEFT
 
  Dim jo As JavaObject = sm
    jo.RunMethod("setTouchmodeMarginThreshold", Array(50%x))

  Dim lv1 As ListView
  lv1.Initialize("lv1")
  For i = 1 To 10
    lv1.AddSingleLine("Action "  & i)
  Next
  sm.SecondaryMenu.AddView(lv1, 0, 0, 100%x - offset, 100%y)
  Dim b1, b2 As Button
  b1.Initialize("b1")
  b2.Initialize("b2")
  b1.Text = "Button1"
  b2.Text = "Button2"
  sm.Menu.AddView(b1, 10dip, 10dip, 100%x - offset - 20dip, 50dip)
  sm.Menu.AddView(b2, 10dip, 60dip, 100%x - offset - 20dip, 50dip)
End Sub
Sub lv1_ItemClick (Position As Int, Value As Object)
  Log(Value)
  sm.HideMenus
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
  If KeyCode = KeyCodes.KEYCODE_BACK AND sm.Visible Then
    sm.HideMenus
    Return True
  End If
  Return False
End Sub
Sub B1_Click
  Log("b1_click")
  sm.HideMenus
End Sub
Sub B2_Click
  Log("b2 click")
  sm.HideMenus
End Sub
 

Douglas Farias

Expert
Licensed User
Longtime User
and about position

sm.Mode = sm.LEFT
sm.Mode = sm.RIGHT

its possible to add UP AND DOWN?
 
Status
Not open for further replies.
Top