Sub movegraph
For l = 250 To 1 Step -1
ImageView2.Left = l
DoEvents
Next
For l = 1 To 250
ImageView2.Left = l
DoEvents
Next
Timer1.Initialize("Timer1",1000)
Timer1.Enabled = True
Timer1_Tick
Sub Timer1_Tick
' move ball left
For l = 250 To 1 Step -1
ImageView2.Left = l
Next
' now move ball back to original position
For l = 1 To 250
ImageView2.Left = l
Next
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private WImageView1 As ImageView
Private position As Int
Private DirectionLeft As Boolean
Private t As Timer
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")
position = WImageView1.Left
DirectionLeft = False
t.Initialize("Timer",10)
t.Enabled = True
End Sub
Sub Timer_Tick
Dim pos As Int = WImageView1.Left
If DirectionLeft Then
If WImageView1.Left > 0 Then
WImageView1.Left = pos - 1
Else
DirectionLeft = False
End If
Else
If WImageView1.Left < 100%x-WImageView1.Width Then
WImageView1.Left = pos + 1
Else
DirectionLeft = True
End If
End If
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private WImageView1 As ImageView
Private position As Int
Private DirectionLeft As Boolean
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")
Move_Right
End Sub
Sub Move_Right
WImageView1.SetLayoutAnimated(1000,100%x-WImageView1.Width,0,100dip,100dip)
Starter.csu.CallSubPlus(Me, "Move_Left", 1000)
End Sub
Sub Move_Left
WImageView1.SetLayoutAnimated(1000,0,0,100dip,100dip)
Starter.csu.CallSubPlus(Me, "Move_Right", 1000)
End Sub