Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim TouchX,TouchY As Float
Dim l1,l2 As Label
Dim p1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
l1.Initialize("lbl1")
l1.Tag="lbl1"
l1.Text="uno"
Activity.AddView(l1,10,10,100,50)
l2.Initialize("lbl2")
l2.tag="lbl2"
l2.Text="due"
Activity.AddView(l2,150,10,100,50)
p1.Initialize("pnl1")
p1.Color=Colors.Transparent
Activity.AddView(p1,0%x,0%y,100%x,100%y)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub pnl1_Touch(Action As Int, X As Float, Y As Float)
Select Action
Case Activity.ACTION_DOWN
TouchX = X
TouchY = Y
Case Activity.ACTION_UP
If (X = TouchX) AND (Y=TouchY) Then
cliccalabel(X,Y)
Else
If (X > TouchX) AND Abs (X-TouchX)>150 Then swipe("dx")
If (X < TouchX) AND Abs (X-TouchX)>150 Then swipe("sx")
End If
Case Else
'non interessano gli step di movimento
End Select
Return True
End Sub
Sub swipe(dir As String)
If dir = "dx" Then
l1.Color=Colors.green
l2.Color=Colors.green
Else
l1.Color=Colors.Red
l2.Color=Colors.Red
End If
End Sub
Sub lbl1_click
l1.text="click"
End Sub
Sub lbl2_click
l2.Text="clack"
End Sub
Sub cliccalabel(x As Float, y As Float)
For Each lbl As Label In Activity.GetAllViewsRecursive
If (x > lbl.Left) AND (x<lbl.Left+lbl.Width) AND (y > lbl.Top) AND (y<lbl.Top+lbl.height) Then
CallSub(Me,lbl.tag&"_click")
Exit
End If
Next
End Sub