LoadLayout in Sliding Panel

squaremation

Active Member
Licensed User
Longtime User
Not sure where I missed this loading the layout in the Sliding Panels in the documentation. So I have been just working with trying to change example form code. Any help much appreciated.:BangHead:. I have been working over the example just to get a working code.

B4X:
   Dim panels(3) As Panel
      Dim lbl As Label

   For i = 0 To panels.Length - 1
      panels(i).Initialize("panels")
                panels(1).LoadLayout("left")    '<----freezes here in debug not initialized
                panels(3).LoadLayout("right)
      panels(i).Color = Colors.Transparent

      lbl.Initialize("")
      lbl.Text = "I'm Panel: " & i
      lbl.TextSize = 20
      lbl.TextColor = Colors.White

      panels(2).AddView(lbl, 20%x, 40%y, 60%x, 30dip)
      Activity.AddView(panels(i), 100%x, 0, 100%x, 100%y - 80dip) 'add the panel to the layout
      Activity.AddMenuItem("Panel #" & i, "Menu")
   Next

I am trying to have menu on each side of screen that slide out/slide back on button_click. Panel in middle is transparent
 

Ricky D

Well-Known Member
Licensed User
Longtime User
have you missed enclosing the "right with a closing " ?

It shouldn't have compiled

regards, Ricky
 
Upvote 0

squaremation

Active Member
Licensed User
Longtime User
Resolved

Ok got it to work by initializing all panels individualy, and remembering in code counting starts from (0). This code works:

B4X:
Dim panels(3) As Panel
   For i = 0 To panels.Length - 1
      panels(0).Initialize("panels")
      panels(1).Initialize("panels")
        panels(2).Initialize("panels")
      
      panels(0).LoadLayout("left")
      
        panels(2).LoadLayout("right")
      
      panels(1).Color = Colors.Transparent 
      Dim lbl As Label
      lbl.Initialize("")
      lbl.Text = "I'm Panel: " & i
      lbl.TextSize = 20
      lbl.TextColor = Colors.White
      panels(1).AddView(lbl, 20%x, 40%y, 60%x, 30dip)
      
      Activity.AddView(panels(0), 100%x, 0, 100%x, 100%y - 80dip) 'add the panel to the layout
      Activity.AddView(panels(1), 100%x, 0, 100%x, 100%y - 80dip)
      Activity.AddView(panels(2), 100%x, 0, 100%x, 100%y - 80dip)
      Activity.AddMenuItem("Panel #" & i, "Menu")


And this will set the middle panel to the default.

B4X:
sd.Initialize
   SlidingPanels.Initialize(sd, panels, True, 150)
   sd.currentPanel = currentPanelBeforePaused - 1
   
   Indicator = SlidingPanels.CreatePageIndicator(panels.Length, InactiveBitmap, 120dip, 16dip)
   Activity.AddView(Indicator, (100%x - 120dip) / 2, 0, 120dip, 16dip)
   Indicator.BringToFront
   ChangePanel(1)'<------ 1 instead of zero

May help another noob like myself:signOops:
 
Upvote 0
Top