Android Question How can i detect which panel was clicked ?

Goldast.XPS

New Member
Hi my firends, im new in B4A and i familiar whit OOP in JS and Java , but i have a many problems with OOP in b4a , i'd better ask you that, is B4A a object oriented language ?

About this topic , i've a question about click on panel in my activity , i have many panel in one activity and i want to detect which panel will be clicked ?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    pl1.Initialize("panel") : pl2.Initialize("panel") : pl3.Initialize("panel") : pl4.Initialize("panel")
    pl5.Initialize("panel") : pl6.Initialize("panel") : pl7.Initialize("panel") : pl8.Initialize("panel")
    pl9.Initialize("panel") : pl10.Initialize("panel") : pl11.Initialize("panel") : pl12.Initialize("panel")
  
    pl1.Tag = 1 : pl2.Tag = 2 : pl3.Tag = 3 : pl4.Tag = 4 : pl5.Tag = 5 : pl6.Tag = 6 : pl7.Tag = 7 :
    pl8.Tag = 8 : pl9.Tag = 9 : pl10.Tag = 10 : pl11.Tag = 11 : pl12.Tag = 12 :

and i define a sub for panel clicks :
B4X:
Sub Panel_Click

    Msgbox("Msg", 'panel tag is ")

End Sub

As you see , i want to get any Tag of a panel that was clicked . Each tag is a one ID for me , i need it .

Thank you for any help
 

johndb

Active Member
Licensed User
Longtime User
Get the object that raised the event.
B4X:
Sub Panel_Click
   dim pnl as panel
   pnl = sender
   Msgbox("Msg", $"panel tag is ${pnl.tag}"$)
End Sub
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
if the Panels are included in the layout "main" .. there is no need to initialise them.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…