Android Question View Name as Variable

mackrackit

Member
Licensed User
Hi,
I have a button click that runs a SUB to create multiple labels. I can give each label a different text value, but I want each label to have a different name with the hopes of writing the data to a file at some point.

This is a snippet of what I have been trying.
B4X:
SherdNum = SherdNum + 1
    
Dim xyz As String
xyz = "lbl_Sherd_" & SherdNum
    
Dim xyz As Label
 

sorex

Expert
Licensed User
as ronell wrote you should store the naming into the view's tag.

B4X:
SherdNum = SherdNum + 1
  
Dim xyz As Label
xyz.initialize("lbl")
xyz.tag="lbl_Sherd_" & SherdNum
xyz.text="text "& SherdNum
then you can use the tag for identification

B4X:
sub lbl_Click
 dim l as label=sender
 log(l.tag & tab & l.text)
end sub
 
Top