Sub Globals
Dim lblCodeLabelsNb = 4 As Int
Dim lblTest(6), lblCodeLabels(lblCodeLabelsNb) As Label
Dim lblTest0, lblTest1, lblTest2, lblTest3, lblTest4, lblTest5 As Label
Dim edtTest(6) As EditText
Dim edtTest0, edtTest1, edtTest2, edtTest3, edtTest4, edtTest5 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
lblTest = Array As Label(lblTest0, lblTest1, lblTest2, lblTest3, lblTest4, lblTest5)
edtTest = Array As EditText(edtTest0, edtTest1, edtTest2, edtTest3, edtTest4, edtTest5)
AddLabels
End Sub
Sub btnFillText_Click
For i = 0 To 5
lblTest(i).Text = "Label " & i & "Text"
edtTest(i).Text = "EditText " & i & "Text"
Next
For i = 0 To lblCodeLabelsNb - 1
lblCodeLabels(i).Text = "Code label " & i & "Text"
Next
End Sub
Sub AddLabels
Dim Left, Top, Width, Height, Space As Int
Left = lblTest(0).Left
Top = lblTest(0).Top + 6 * lblTest(0).Height + 20dip
Width = 150dip
Height = 40dip
Space = 5dip
For i = 0 To lblCodeLabelsNb - 1
lblCodeLabels(i).Initialize("lblCodeLabels")
lblCodeLabels(i).Tag = i
lblCodeLabels(i).Color = Colors.Blue
Activity.AddView(lblCodeLabels(i), Left, Top + i * (Height + Space), Width, Height)
Next
End Sub
Sub lblCodeLabels_Click
Dim lbl As Label
Dim Index As Int
lbl = Sender
Index = lbl.Tag
Activity.Title = "Code label " & Index & " clicked"
End Sub