iterate views of panel

jake

Member
Licensed User
Longtime User
For a panel containing different types of child views, I know I can conditionally select just the label views. Is there a way to change the text color of these labels? What I have below doesn't get the job done.

B4X:
For i=0 To pnlStats.NumberOfViews-1
               If pnlStats.GetView(i) Is Label Then
                  If intMainColor>300 Then
                     pnlStats.GetView(i).TextColor=Colors.black
                  Else
                     pnlStats.GetView(i).TextColor=Colors.white
                  End If 
               End If
            Next
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
For a panel containing different types of child views, I know I can conditionally select just the label views. Is there a way to change the text color of these labels? What I have below doesn't get the job done.

B4X:
Dim v As View
           For i=0 To pnlStats.NumberOfViews-1
                  If pnlStats.GetView(i) Is Label Then
                  If intMainColor>300 Then
                     Activity.GetView(i).TextColor=Colors.black
                  Else
                     Activity.GetView(i).TextColor=Colors.white
                  End If 
               End If
             Next

GetView returns a View and thus does not have a TextColor property. You have to cast this view to the label type.
B4X:
Dim lbl as Label
lbl = GetView(i)
lbl.TextColor = ...
 
Upvote 0

jake

Member
Licensed User
Longtime User
Okay thank you for the tip. I think I will need to cast to a label, change its text color, then put it back into pnlStats.getview(i). Will give this a try!
 
Upvote 0
Top