I developed an example project for an italian member (this is the reason why the project attached to this post is in Italian).
To retrieve all the labels added in a panel by Designer and put them in an array, I used GetAllViewsRecursive:
Texts and Tags will be right but the array seems to be composed only of last label (all references to the last label).
I solved using:
but I don't understand why you can successfully change some properties of the "current label" into the loop but the addition to the array fails.
[In the project, "Estrai" creates a list of 5 random number, which must be highlighted]
To retrieve all the labels added in a panel by Designer and put them in an array, I used GetAllViewsRecursive:
B4X:
' Globals
Private arrLabels(90) As Label
' Activity_Create
Dim Index As Int = 0
For Each lbl As Label In pnlLabels.GetAllViewsRecursive
arrLabels(Index) = lbl
lbl.Text = Index + 1
lbl.Tag = Index + 1
Index = Index + 1
I solved using:
B4X:
For I = 0 to pnlLabels.NumberOfViews - 1
Dim lbl As Label = pnlLabels.Get(I)
arrLabels(Index) = lbl
lbl.Text = Index + 1
lbl.Tag = Index + 1
Index = Index + 1
but I don't understand why you can successfully change some properties of the "current label" into the loop but the addition to the array fails.
[In the project, "Estrai" creates a list of 5 random number, which must be highlighted]
Attachments
Last edited: