Android Question [SOLVED] Sender Tag value irrespective of object type?

RandomCoder

Well-Known Member
Licensed User
Longtime User
Here is the scenario, I have a scrollview loaded with panels and each panel contains an imageview and a couple of labels. The user is able to trigger an event by pressing on the panel, the imageview or either of the labels and I handle this by using three different subs. Each sub casts Sender to the correct object type so that the tag value can be read.

Is it possible to have just one sub and get the tag value of the object that was clicked? I've searched the forum and not found the answer.
I've tried....
B4X:
Dim item As Object=Sender
Log(item.Tag)
But this gives an error of unknown type.

So in essence, is it possible to retrieve the Tag value from an object of unspecified type?

Thanks,
RandomCoder
 

DonManfred

Expert
Licensed User
Longtime User
i think it should be something like

B4X:
IF Sender is Button then
  dim item as Button
  LOG(item.Tag)
else if Sender = ImageView then
  dim item as Imageview
  LOG(item.Tag)
end if
 
Upvote 0
Top