Android Question View Name as Variable

Discussion in 'Android Questions' started by mackrackit, May 28, 2019.

  1. mackrackit

    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.
    Code:
    SherdNum = SherdNum + 1
        
    Dim xyz As String
    xyz = 
    "lbl_Sherd_" & SherdNum
        
    Dim xyz As Label
     
  2. ronell

    ronell Well-Known Member Licensed User

  3. sorex

    sorex Expert Licensed User

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

    Code:
    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

    Code:
    sub lbl_Click
     
    dim l as label=sender
     
    log(l.tag & tab & l.text)
    end sub
     
    José J. Aguilar likes this.
  4. mackrackit

    mackrackit Member Licensed User

    Thanks to both of you!

    Using the tag makes sense. I will give it a try.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice