Array as Label?

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
I was able to create an array of ImageViews using "Array As ImageView(...)", but when I try "Array As Label(...)", it gives me an error message (just says "error"). Is it not possible to create an array of labels.
 

agraham

Expert
Licensed User
Longtime User
Is it not possible to create an array of labels.
Yes, but you need instances of the Label type to populate it.

B4X:
   Dim L(10) As Label
   For i = 0 To L.Length
      Dim LL As Label
      Ll.Initialize("")
      L(i) = LL
   Next

   Dim L2(0) As Label
   L2 = Array As Label( L(0), L(1), L(2 ))
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
I already had the labels set up in Designer and loaded the layout, but in looking at your code, I saw my mistake.

In Sub Global where I Dimmed the labels in the layout, I followed that with
Dim Labels as Label
instead of
Dim Labels() as Label

I fixed it and it works. Thanks.

I need to make an array of 50+ Labels and Buttons because of not being able to set different font sizes for the same Views in different Variants, so I'll have to change them programmatically, unless you can think of something I'm doing wrong in Designer.
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
I thought fonts were automatically scaled for the different variants, or have I misunderstood something
 
Upvote 0
Top