Click Event - Panels inside Scrollview

Catom

Member
Licensed User
Longtime User
I think I've used so many bits of code learning how to do a Scrollview with Labels so now I don't know how to add click events :)

I have a ScrollView (made with designer) named buscaResults.

B4X:
Dim Panel0 as Panel
Dim PanelTop, PanelHeight as Int
Panel0=buscaResults.Panel
Panel0.Color=Colors.RGB(247,247,247)
PanelTop=0 : PanelHeight=99dip

For i = 0 To MenuItems.Size - 1
   Dim Panel1 As Panel
   Dim ImageView1 As ImageView
   Dim Label1, Label2, LabelKM As Label

   Panel1.Initialize("")
   Panel0.AddView(Panel1,0,PanelTop,buscaResults.Width,PanelHeight)

   Label1.Initialize("")
   Panel1.AddView(Label1,80dip,5dip,240dip,30dip)
   Label1.Tag="Label1"
   Label1.Text= Map1.Get("nombre")
   Label1.TextColor = Colors.RGB(52,92,00)
   Label1.TextSize=22
   Label1.Typeface = fnt_Header
      
   Label2.Initialize("")
   Panel1.AddView(Label2,80dip,40dip,240dip,50dip)
   Label2.Tag="Label2"
   Label2.TextSize=14
   Label2.Text=Map1.Get("direccion")

   ImageView1.Initialize("")
   Panel1.AddView(ImageView1,5dip,5dip,65dip,65dip)
   IconTurn = Map1.Get("cat")
   ImageView1.Bitmap= IconTurn

   PanelTop=PanelTop+PanelHeight+1dip
   Panel0.Height=PanelTop
Next

That works fine and creates a list successfully. But now I don't know how to add Click events to each view :(

Thanks for any help!
 

Catom

Member
Licensed User
Longtime User
Well, Reflection Library didn't help, but Klaus solution did!!

Initialize any object with a TagName and then calling a Sub Click did the trick :sign0060:

A remote thanks to Klaus :wav:
 
Upvote 0
Top