Something like this typing here manually, not checked:
B4X:
Sub Globals
Dim Buttons() as Button
end sub
Sub Activity_Create(FirstTime As Boolean)
For i=0 to X-1 'think about needed X qty
dim a as Button
a.Initialize("Buttons")
Activity.AddView(a, i1, i2, w, h) 'think about coordinates and dimentions
Buttons(i) = a 'try to use these names of buttons
next
Sub Buttons_Click
Dim a as Button
a = Sender 'but here, seems, anyway it needs to check all the buttons to understand which is pressed
end sub
Sub Activity_Create(FirstTime As Boolean)
For i=0 to X-1 'think about needed X qty
dim a as Button
a.Initialize("Buttons")
Activity.AddView(a, i1, i2, w, h) 'think about coordinates and dimentions
Buttons(i) = a 'try to use these names of buttons
next
Sub Buttons_Click
Dim a as Button
a = Sender 'but here, seems, anyway it needs to check all the buttons to understand which is pressed
Sub Globals
Dim Buttons(X) as Button 'think about needed X qty
end sub
Sub Activity_Create(FirstTime As Boolean)
For i=0 to X-1
buttons(i).Initialize("Buttons")
Activity.AddView(buttons(i), i1, i2, w, h) 'think about coordinates and dimentions
next
Sub Buttons_Click
Dim a as Button
a = Sender 'but here, seems, anyway it needs to check all the buttons to understand which is pressed
end sub
You should set the Tag propety to know what button raised the event.
B4X:
Sub Globals
Dim Buttons(X) as Button 'think about needed X qty
End Sub
Sub Activity_Create(FirstTime As Boolean)
For i=0 to X-1
Buttons(i).Initialize("Buttons")
Activity.AddView(Buttons(i), i1, i2, w, h) 'think about coordinates and dimentions
Buttons(i).Tag = i
Next
End Sub
Sub Buttons_Click
Dim a As Button
a = Sender
Select a.Tag
Case 0 ' buttons(0)
.
Case 1 ' buttons(1)
.
End Select
End Sub