B4A Library jfeinstein10 SlidingMenu library

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jan 7, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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:
    Code:
    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, 
    00100%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, 
    10dip10dip100%x - offset - 20dip50dip)
       sm.Menu.AddView(b2, 
    10dip60dip100%x - offset - 20dip50dip)
    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
     

    Attached Files:

    Last edited: Dec 19, 2016
    koaunglay, Myron, edris and 3 others like this.
  2. Informatix

    Informatix Expert Licensed User

    The author wants to be cited in any app using his library. And the licence must appear too. From https://github.com/jfeinstein10/SlidingMenu:
     
  3. Theera

    Theera Well-Known Member Licensed 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?

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

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

    No. You should set the path to the res folder.
     
    Theera likes this.
  5. M6SOFT

    M6SOFT Member Licensed 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:

    Code:
    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
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    This is a bug that will be fixed in the next version.

    For now you need to copy the resources of both projects to each other. The google map res folder should be identical to this library res folder.
     
  7. M6SOFT

    M6SOFT Member Licensed User

    Hi Erel,
    Thanks for reply.
    After copy res folders i have 2 identical with duplicated all files. Then it cause:
    I will be waiting for new version.
    Thanks
    greg
     
  8. tchart

    tchart Active Member Licensed 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?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Not all the API is currently exposed. It should be quite simple to access most of the API that is not exposed with JavaObject.
     
  10. Roger C

    Roger C Member Licensed 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:
    Code:
    #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...
     

    Attached Files:

  11. Erel

    Erel Administrator Staff Member Licensed User

    You should also add a reference to SlidingMenuWrapper library in the libraries tab.
     
  12. Roger C

    Roger C Member Licensed 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. :)
     
  13. Douglas Farias

    Douglas Farias Expert Licensed User

  14. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Code:
    Dim jo As JavaObject = SlidingMenu1
    jo.RunMethod(
    "setTouchmodeMarginThreshold"Array(50%x))
     
  15. Douglas Farias

    Douglas Farias Expert Licensed User

    this works fine 40000% best *-*

    here is the code if help someone
    Code:
    #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, 
    00100%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, 
    10dip10dip100%x - offset - 20dip50dip)
      sm.Menu.AddView(b2, 
    10dip60dip100%x - offset - 20dip50dip)
    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
     
  16. Douglas Farias

    Douglas Farias Expert Licensed User

    and about position

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

    its possible to add UP AND DOWN?
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    No. Only horizontal scrolling is supported.
     
    Douglas Farias likes this.
  18. Johnmcenroy

    Johnmcenroy Active Member Licensed User

    I have an error: inconvertible types using the following code:
    Code:
    sm.Menu.AddView(smScroll,10dip10dip200dip100%y)
    smScroll is CustomListView

    Update
    Solved
    It must be:
    Code:
    sm.Menu.AddView(smScroll.AsView,10dip10dip200dip100%y)
    Thanks
    John
     
    Last edited: Aug 3, 2014
    gadgetmonster likes this.
  19. Douglas Farias

    Douglas Farias Expert Licensed User

    @Erel what the os version is required? 2.3+ ?
     
    KZero likes this.
  20. Erel

    Erel Administrator Staff Member Licensed User

    Should work on all versions.
     
    Douglas Farias likes this.
Loading...