Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim btnList As List
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")
btnList.Initialize
Dim width, offsetX, offsetY As Int
width = 100dip
offsetX = (100%x - width * 3 - 10dip * 2) / 2
offsetY = (100%y - width * 3 - 10dip * 2) / 2
For x = 0 To 2
For y = 0 To 3
Dim b As Button
b.Initialize("button") 'All buttons share the same event sub
b.TextSize = 30
' b.Text = "test"
' Activity.AddView(b,offsetX + x * (width + 10dip), offsetY + y * (width + 10dip), width, width)
Activity.AddView(b,offsetX + x * (width + 5dip), offsetY + y * (width + 5dip), width, width)
b.Text = "value from 'product'"
b.Tag = "value from 'ProductID'"
Dim m As Map ' Dim map to be used for each button. The map(s) are added to the list
m.Initialize
m.Put("x",x) ' Store x and y value in the Map
m.Put("y",y)
m.Put("button",b) 'store a reference to this view
btnList.Add(m) ' Add the map to the list
'ProdButtons(x, y) = b 'store a reference to this view
Next
Next
End Sub
Sub button_Click
Dim btn As Button = Sender
For i = 0 To btnList.Size-1
Dim m As Map = btnList.Get(i)
If btn = m.Get("button") Then
Log($"ButtonClicked(${m.Get("x")},${m.Get("y")})"$)
End If
Next
End Sub