Android Question array of views

DPaul

Active Member
Licensed User
Longtime User
Hi,

The comments on my alpha channel question, lead me to believe i could simplify my
code by dozens of lines, but now i hit a snag.

Al label has many properties that i can set (color, text, textcolor, enabled...etc)

Now i define an array of views lblFrom(12) and i assign 12 labels to it. So far so good.
But
For i = 1 To 12
lblFrom(i).Enabled = True => allowed!
lblFrom(i).text = "0" => syntax error
Next

It would appear that making an arry of views, strips away some of the properties of the individual view,
in my case labels (eg. label.textcolor =....)

I cannot find a direct reference to this .
Any ideas or i'm back to square 1 ?

thx,
Paul
 

Semen Matusovskiy

Well-Known Member
Licensed User
Very doubt in "syntax error". In run time - yes, it will be error.
In B4A Dim lblFrom (12) means allocation of array from 12 elements with indexes from 0 to 11.
That's why you must use For i = 0 To 11.

It would appear that making an arry of views, strips away some of the properties of the individual view,
It's not so.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Unfortunately you don't give enough information.
Now i define an array of views lblFrom(12)
How did you declare lblFrom(12)
Dim lblFrom(12) As Label, here you don't loos propeties
or
Dim lblFrom(12) As View, here you loose properties
or
Dim lblFrom(12) As B4XView, here acces the B4XView properties which has the Label properies, no loose of properties.
 
Upvote 0
Top