Android Question Accesing propertie of a label created at runtime?

MarianoD

Member
Licensed User
Longtime User
Hello everybody, please apologize my english...

I am doing an App, and the forum was very helpfull, but i cant figure how to do this:

My app has an Scrollview, with a Panel inside, and at runtime i created some labels added to the panel (sv.panel.addview) and asigned an "event name" when initializing to use Click event. That works great! I can catch MyLabel1_Click events succefully and do some actions!

Each of my labels has in their "tag" property some info i need to do each action (an specific url)

Buuuuut the problem is that inside "MyLabel1_Click" event (or MyLabel2, 3, etc.) i cant use "MyLabel1.Tag", it says "undeclared variable" when compiling. It is obvious that MyLabel1 does not exists until program is runnig, i know, but how to access the tag property without this compilatrion error? I need to loop throgh all labels and find the correct one, and then take the "tag" property?

Can you please help me?
Thanks!
 

DonManfred

Expert
Licensed User
Longtime User
Create ONE event sub. label_click (initialize all labels with "label" as eventname.

inside your click event you can use
B4X:
dim lbl as label = sender
' Now work with the lbl
No matter which label you clicked you get the right reference.
 
Upvote 0

MarianoD

Member
Licensed User
Longtime User
Create ONE event sub. label_click (initialize all labels with "label" as eventname.

inside your click event you can use
B4X:
dim lbl as label = sender
' Now work with the lbl
No matter which label you clicked you get the right reference.

Thank you very much DonManfred! It works great!
 
Upvote 0
Top