Labels

fellow

Member
Licensed User
Longtime User
As a long time devotee of visual Basic I think basic4android is very user friendly.
One thing - how do you subsequently identify views, such as labels, that have been added programmatically to a scrollview at runtime? I would use the designer for this but it won't allow me to nominate a scrollview panel as a parent.
 

fellow

Member
Licensed User
Longtime User
Labels etc.

Klaus,

Many thanks for that.
Unless I misunderstand it fundamentally, the lists shown are populated at runtime and then rely on a click event thereafter. I still cannot see how I can change the value of a particular label after an event if I cannot "name" it. Creating views in the designer (except scrollview) allows sensible naming and therefore permanent identification.
The other issue I have found is that, while the Designer will increment a view index when added (i.e. Label2) to ensure a unique identity, if there is already a layout loaded I am not sure if that (hidden) process continues.
Is the answer to create mixed items in a scrollview as a table array?
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
You can still "name" your label. However you need to have a unique identifier, maybe in the tag so you can identify it.
Lets say you want to create a new label with a permanent handle so you dont lose it.
Dim a Label in 'Globals':
B4X:
Dim Label1 as Label

and in activity create initialise it and add it to the scrollview.

So you should be able to change its value if you need to.

If you have more labels then create an array or list of labels.

If you need to find a particular view from a parent (like scrollview's panel) make sure you put something in the tag to identify it.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The instance of a View is independent of the name of the variable used to Dim it and it can be assigned to any View variable of the correct type. If you need to identify a particular instanceof a View that might not still be assigned to its original variable then the identification needs to travvel with it in its Tag property - which can contain anything, it is not restricted to strings.
 
Upvote 0
Top