Android Question looping thru labels

merlin2049er

Well-Known Member
Licensed User
Longtime User
I looked at some of the examples in the pdf and online but couldn't quite figure out how to apply changes to "x" number of labels in a for next loop.

Just like to clean up my code a bit.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Then how about this,
B4X:
For i = 0 To Activity.NumberOfViews - 1
      If Activity.GetView(i) Is Button    OR _
         Activity.GetView(i) Is EditText  OR _
         Activity.GetView(i) Is CheckBox  OR _
         Activity.GetView(i) Is RadioButton Then
   
       Else If Activity.GetView(i) Is Label Then
           Dim lbl As Label
           lbl = Activity.GetView(i)
       End If
  Next
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
sweet.

' oloron font
Dim i As Int


For i = 0 To Activity.NumberOfViews - 1

If Activity.GetView(i) Is Label Then

Dim lbl As Label

lbl = Activity.GetView(i)
lbl.Typeface = oloron

End If

Next

That works fine. I loaded the font in activity_create (first time).
 
Upvote 0

beni_feld

Member
Licensed User
Longtime User
You can use the Tag property for each label and set it by the designer to "lbl"
Now use the Tag property to identify the label:

B4X:
Dim vi As View
Dim lb As Label
 
For i=0 To activity.NumberOfViews-1
   vi=Activity.GetView(i)
 
   If vi.Tag="lbl" Then
       lb=activity.GetView(i)
      'lb.Color=Colors.Transparent
      'lb.TextColor=Colors.RGB(0,0,139)
   end if
Next

BN
 
Upvote 0
Top