Android Question Getting views tag's

Discussion in 'Android Questions' started by Sub7, Feb 15, 2015.

  1. Sub7

    Sub7 Active Member Licensed User

    Hola,
    how do i get the view tag using a single sub? there are 60 imageviews.
    This code generate a clv filled with images, once i click one image i need to know which one was clicked.

    Code:
    Sub btn_selectimg_Click
        
       clv.Initialize(Me, 
    "clv")
       
    Activity.AddView(clv.AsView, 080dip , 100%x100%y)

      
    Dim p As Panel
      p.Initialize(
    "")
      p.color = 
    Colors.ARGB(255,235,235,235)

       clv.Add(p, 
    500dipNull)
       p.LoadLayout(
    "clvlayout")
        
       
    For x = 0 To p.NumberOfViews -1
       
    If p.GetView(x) Is ImageView Then
       p.GetView(x).SetBackgroundImage(
    LoadBitmapSample(File.DirAssets, "img_s/"& x&"_image.png"100100))

       
    'Add tag 
       p.GetView(x).Tag = x

       
    Log(p.GetView(x).Tag) 'I need this outside frome this sub
         End If    
       
    Next

    End Sub


    Sub clv_ItemClick(Position As Int, Value As Object)

    'here i need to get the clicked imageview tag

    End sub
    Thanks
     
  2. DonManfred

    DonManfred Expert Licensed User

    i believe Value is the panelobject. if so then i gues you you can use
    Code:
    dim p as panel = Value
    For Each v As View In p.GetAllViewsRecursive
      [..]
    Next
     
  3. Sub7

    Sub7 Active Member Licensed User

    My code is wrong , i'll have to change everything.

    Position is empty, value too. there are no rows in the customlistview i just 1 big layout.
     
  4. Sub7

    Sub7 Active Member Licensed User

    Code:
    Sub pnl_background_Click


       
    For Each v As View In pnl_background.GetAllViewsRecursive
      
    Log(v.Tag)

    Next
    This get all views tags, i need the clicked one!
     
  5. Cableguy

    Cableguy Expert Licensed User

    assuming all imageviews trigger the same event...

    Code:
    Sub ImgView_Click
    dim v as ImageView
    v = 
    Sender
    Log(v.Tag)
    End Sub
    This will log the clicked Image view Tag propertie as long as it is NOT void
     
    Sub7 likes this.
  6. Sub7

    Sub7 Active Member Licensed User

    Thanks, i forgot to change the event name.
     
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