Sub Globals
'These global variables will be redeclared each time the activity is created.
Private ScrollView1 As ScrollView
Dim btn As Button
Private map1 As Map
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
btn.Initialize("btn")
' for example only *****
map1.Initialize
map1.Put(1,True)
map1.Put(2,True)
map1.Put(3,False)
map1.Put(4,True)
map1.Put(5,False)
'***********************
drawButtons
End Sub
Sub drawButtons
Dim pad As Int = 4dip
Dim x As Int = pad
Dim y As Int = pad
Dim w As Int = (ScrollView1.Width - 5 * pad) / 3
Dim h As Int = (ScrollView1.Height - 6 * pad) / 3
For i = 0 To map1.Size-1
Dim btn As Button
btn.Initialize("btn")
ScrollView1.Panel.AddView(btn, x, y, w, h)
btn.Textsize = 40
btn.TextColor = xui.Color_White
If map1.GetValueAt(i) = True Then
btn.Color = xui.Color_Green
btn.Text = map1.GetKeyAt(i)
Else
btn.Color = xui.Color_Red
btn.Text = map1.GetKeyAt(i)
End If
x = x + w + pad
If ((i Mod 3) = 2) Then
x = pad
y = y + pad + h
End If
btn.Tag = i
Next
End Sub