Sub Process_Globals
Type Player(Name As String, Values() As Int)
Type PlayerColumn (Player As Player, Column As Int)
Dim Players As List
Dim NUM_COLUMNS As Int : NUM_COLUMNS = 6
Dim ROW_HEIGHT As Int : ROW_HEIGHT = 60dip
Dim PLAYER_NAME_WIDTH As Int : PLAYER_NAME_WIDTH = 100dip
End Sub
Sub Globals
Dim TopPanel As Panel
Dim BottomPanel As Panel
Dim ScrollView1 As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Players.Initialize
For i = 0 To 29
Dim p As Player
p.Name = "Player " & (i + 1)
Dim values(NUM_COLUMNS) As Int
p.Values = values
Players.Add(p)
Next
End If
Activity.LoadLayout("1")
TopPanel.Width = 100%x
BottomPanel.Width = 100%x
BottomPanel.Top = 100%y - BottomPanel.Height
ScrollView1.Height = BottomPanel.Top - ScrollView1.Top
ScrollView1.Width = 100%x
CreateListOfPlayers(30)
End Sub
Sub CreateListOfPlayers(Count As Int)
ScrollView1.Panel.Height = Count * ROW_HEIGHT
Dim btnWidth As Int
btnWidth = (ScrollView1.Width - PLAYER_NAME_WIDTH) / NUM_COLUMNS
For i = 0 To Count - 1
Dim p As Player
p = Players.Get(i)
Dim et As EditText
et.Initialize("PlayerName")
ScrollView1.Panel.AddView(et, 0, i * ROW_HEIGHT + 5dip, PLAYER_NAME_WIDTH, ROW_HEIGHT - 10dip)
et.Text = p.Name
et.SingleLine = True
et.Tag = p
et.ForceDoneButton = True
For c = 0 To NUM_COLUMNS - 1
Dim pc As PlayerColumn
pc.Player = p
pc.Column = c
Dim b As Button
b.Initialize("Button")
ScrollView1.Panel.AddView(b, PLAYER_NAME_WIDTH + c * btnWidth, _
i * ROW_HEIGHT, btnWidth, ROW_HEIGHT)
b.Tag = pc
b.Text = p.Values(c)
Next
Next
End Sub
Sub PlayerName_EnterPressed
Dim v As EditText
v = Sender
Dim P As Player
P = v.Tag
P.Name = v.Text
End Sub
Sub Button_Click
Dim b As Button
b = Sender
Dim pc As PlayerColumn
pc = b.Tag
Dim p As Player
p = pc.Player
p.Values(pc.Column) = p.Values(pc.Column) + 1
b.Text = p.Values(pc.Column)
End Sub