I am expecting that this code should create 6 panels. each with a label on top indicating the panel number. However, when I run this code, all 6 panels are created just fine, but only the first label is created on the first panel, while the other 5 panels are just blank.
I'm sure I am just overlooking something simple.
Anyone able to spot my mistake?
Also, I haven't gotten there yet, but I am assuming to detect which panel's child view triggered an event I will just set the 'sender' equal to the view's tag, right?
Thanks.
Eric H
I'm sure I am just overlooking something simple.
B4X:
Sub Activity_Create(FirstTime As Boolean)
'panel gradient setup
Dim grPanel As GradientDrawable
Dim grPanelColors(2) As Int
grPanelColors(0) = Colors.RGB(25,25,25)
grPanelColors(1) = Colors.RGB(50,50,50)
grPanel.Initialize("BOTTOM_TOP", grPanelColors)
grPanel.CornerRadius = 10dip
'create sound panels
Dim spHeight As Int = 80dip
For i = 0 To 5
Dim p As Panel
p.Initialize("")
p.Background = grPanel
p.Tag = ("p" & i)
Log("Panel " & p.Tag & " loaded")
Activity.AddView(p, 0, spHeight * i, Activity.Width, spHeight)
' create a label for the panel
Dim l As Label
l.Initialize("")
l.TextSize = 24
l.Tag = ("l" & i)
l.Gravity = Gravity.CENTER_HORIZONTAL
l.Text = ("Panel " & i)
Log("Label " & l.Tag & " loaded")
p.AddView(l, p.Left, p.Top, p.Width, 30dip)
Next
End Sub
Anyone able to spot my mistake?
Also, I haven't gotten there yet, but I am assuming to detect which panel's child view triggered an event I will just set the 'sender' equal to the view's tag, right?
Thanks.
Eric H