Android Question Getting views tag's

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.

B4X:
Sub btn_selectimg_Click
    
   clv.Initialize(Me, "clv")
   Activity.AddView(clv.AsView, 0, 80dip , 100%x, 100%y)

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

   clv.Add(p, 500dip, Null)
   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", 100, 100))

   '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
 

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.
 

Sub7

Active Member
Licensed User
i believe Value is the panelobject. if so then i gues you you can use
B4X:
dim p as panel = Value
For Each v As View In p.GetAllViewsRecursive
  [..]
Next
B4X:
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!
 

Cableguy

Expert
Licensed User
assuming all imageviews trigger the same event...

B4X:
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
 
Top