I create 16 buttons programmatically and I want for all the buttons to be invisible when any of the buttons are clicked. The code I use to create the buttons are below.
B4X:
Dim x, y As Int
Dim width, offsetX, offsetY As Int
width = 37dip
offsetX = 20'(100%x - width * sw - 10dip * 2 ) / 2
offsetY = 20'(100%y - width * sw - 10dip * 2) / 2
Dim Buttons(8, 2) As Button
For x = 0 To sw
For y = 0 To 1
Dim b As Button
b.Initialize("button") 'All buttons share the same event sub
Activity.AddView(b,offsetX + x * (width + 3dip), offsetY + y * (width + 3dip), width, width)
Buttons(x, y) = b 'store a reference to this view
Next
Next