After loading a layout with labels and a textarea, I am adding blocks of labels, via code, according to this code:
Each label has a tag in the form "x,color name" (eg. "1,blue"). I need to loop through the labels and find the tag for a particular block and color and then change its border to make it black.
My problem is the loop.
I tried using:
but this crashes when it finds the textarea, with a ClassCastException. I know the loop is wrong but I am stuck. Any help is welcome.
B4X:
Dim myWidth As Int
myWidth=15dip
For y=1 To 2
For x=1 To 14
Dim cLabel As Label
cLabel.Initialize("")
cLabel.Tag=block & "," & mynames(y,x)
'Log(cLabel.Tag)
Gauge.RootPane.AddNode(cLabel,l+(x*(myWidth+2)),t+((y-1)*(myWidth+2)),myWidth, myWidth)
Dim r, g, b As Int
Dim RGBColor() As String
RGBColor=Regex.Split(",", mycolors(y,x))
r=RGBColor(0)
g=RGBColor(1)
b=RGBColor(2)
cLabel.Style=$"-fx-background-color:rgb(${r},${g},${b});"$
Next
Next
Each label has a tag in the form "x,color name" (eg. "1,blue"). I need to loop through the labels and find the tag for a particular block and color and then change its border to make it black.
My problem is the loop.
I tried using:
B4X:
For Each lbl As Label In Gauge.RootPane.GetAllViewsRecursive
Log(lbl.Tag)
If lbl.Tag="1," & row(2) Then
lbl.Style="-fx-border-width: 2;"
End If
Next
but this crashes when it finds the textarea, with a ClassCastException. I know the loop is wrong but I am stuck. Any help is welcome.