Sub Process_Globals
End Sub
Sub Globals
Dim sd As SlidingData 'The object that holds the for SlidingPanels
Dim btnLeft, btnRight As Boolean
Dim startX, startY As Float '<-new global variables
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Create the panels.
' Here we create 2 panels with a different layout in each
Dim panels(2) As Panel
'First initialise each panel
panels(0).Initialize("panels")
panels(1).Initialize("panels")
' Now load a layout into each one
panels(0).LoadLayout("scr1")
panels(1).LoadLayout("scr2")
' Add the panels
Activity.AddView(panels(0), 100%x, 0, 100%x, 100%y) 'add the panel to the layout
Activity.AddView(panels(1), 100%x, 0, 100%x, 100%y) 'add the panel to the layout
'Initialize the SlidingData object and set the array of panels.
sd.Initialize
sd.Panels = panels
'Call SlidingPanels.Initialize to prepare the animation objects.
SlidingPanels.Initialize(sd, 400) ' 400 is the duration of the slide
'The last call to ChangePanel brings the first panel.
ChangePanel(True) 'Current code expects the first call to be with Left = True.
End Sub
Sub Panels_Touch (Action As Int, X As Float, Y As Float)
Select Action
Case Activity.ACTION_DOWN
startX = X
startY = Y
Case Activity.ACTION_UP
If Abs(y - startY) > 20%y Then Return
If X - startX > 30%x AND btnRight = True Then
ChangePanel(False)
Else If startX - x > 30%x AND btnLeft = True Then
ChangePanel(True)
End If
End Select
End Sub
Sub Left_Click
ChangePanel(True)
End Sub
Sub Right_Click
ChangePanel(False)
End Sub
'**** These two subs are requred for handling the sliding ***
Sub ChangePanel(Left As Boolean)
'disable the buttons during the animation
btnLeft = False
btnRight = False
'Call SlidingPanels.ChangePanel to actually change the panels.
SlidingPanels.ChangePanel(sd, Left)
End Sub
Sub Animation1_AnimationEnd
'This event is raised when the animation finishes. You should call SlidingPanels.AnimationEnd from this sub.
SlidingPanels.AnimationEnd(sd)
'Enable the Left and Right buttons (unless there are no more panels).
If sd.currentPanel = sd.panels.Length - 1 Then btnLeft= False Else btnLeft = True
If sd.currentPanel = 0 Then btnRight = False Else btnRight = True
End Sub
Sub Activity_Resume
End Sub