Android Question create Dynamic panel and initialize

victormedranop

Well-Known Member
Licensed User
Longtime User
Hi, I'm trying to create dynamic panels and initialize them, but cant find how to.
some one need some help

try with, in globals
B4X:
For i = 0 To 10 -1
   Dim picture_panel(i) As Panel
Next

that works.

but initialize is other thing

B4X:
For x = 0 To 10 -1
  picture_panel(x).Initialize("picture_panel"&x") 
Next

I got this error
java.lang.ArrayIndexOutOfBoundsException: length=9; index=9

but I can initialize individualy
B4X:
picture_panel(0).Initialize("picture_panel0")
 

victormedranop

Well-Known Member
Licensed User
Longtime User
just found the code
B4X:
Dim panels(3) As Panel
For i = 0 To panels.Length - 1
panels(i).Initialize("panels")
panels(i).Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
Dim lbl As Label
lbl.Initialize("")
lbl.Text = "I'm Panel: " & i
lbl.TextSize = 20
lbl.TextColor = Colors.White
panels(i).AddView(lbl, 20%x, 40%y, 60%x, 30dip)
Activity.AddView(panels(i), 100%x, 0, 100%x, 100%y - 60dip) 'add the panel to the layout
Activity.AddMenuItem("Panel #" & i, "Menu")
Next
 
Upvote 0
Top