Sub Process_Globals
Private scrollTimer As Timer
Private lastScrollTime As Long
End Sub
Sub Globals
Private itemSize As Int
Private HorizontalScrollView1 As HorizontalScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
scrollTimer.Initialize("scrollTimer", 50)
End If
Activity.LoadLayout("1")
itemSize = HorizontalScrollView1.Width / 3
HorizontalScrollView1.Panel.Width = itemSize * 10
For i = 0 To 9
Dim p As Panel
p.Initialize("")
p.Color = Rnd(0x80000000, -1)
HorizontalScrollView1.Panel.AddView(p, itemSize * i, 0, itemSize, HorizontalScrollView1.Panel.Height)
Next
End Sub
Sub Button1_Click
HorizontalScrollView1.ScrollPosition = Max(0, HorizontalScrollView1.ScrollPosition - itemSize)
End Sub
Sub Button2_Click
HorizontalScrollView1.ScrollPosition = Min(HorizontalScrollView1.Panel.Width, HorizontalScrollView1.ScrollPosition + itemSize)
End Sub
Sub HorizontalScrollView1_ScrollChanged(Position As Int)
If lastScrollTime > DateTime.Now Then Return
If scrollTimer.Enabled = False Then scrollTimer.Enabled = True
lastScrollTime = DateTime.Now
End Sub
Sub ScrollTimer_Tick
If lastScrollTime + 100 < DateTime.Now Then
scrollTimer.Enabled = False
Dim sp As Int = HorizontalScrollView1.ScrollPosition
lastScrollTime = DateTime.Now + 100
HorizontalScrollView1.ScrollPosition = Round(sp / itemSize) * itemSize
End If
End Sub