Android Question [SOLVED] Tag is set, but returns Null when read

Sandman

Expert
Licensed User
Longtime User
In a layout I have a custom view (so B4XView). In it I add an ImageView, which has a value for Tag set. When I click that ImageView and recieve the event, the tag is Null.
B4X:
Private Sub myFineCustomView_Click
    Dim tmp As B4XView = Sender
    Log(tmp.Tag)
End Sub
This logs Null.

I feel I should be able to get the Tag here, am I missing something obvious?
(Might be worth to note that exact same code works fine in B4J.)
 

RichardN

Well-Known Member
Licensed User
Longtime User
Your ImageView is a child of the Custom View Is that correct?

Maybe Sender is returning the Parent View which has no Tag property set?
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
When stripping down my project to the bare minimum I found the issue:
B4X:
#If B4J
Private Sub myGreatCustomView_Click (EventData As MouseEvent)
#Else
Private Sub myFineCustomView_Click
#End If
    Dim tmp As B4XView = Sender
    Log(tmp.Tag)
End Sub

Turns out B4X doesn't consider the event "myGreatCustomView_Click" to be the same as "myFineCustomView_Click". ?‍♂️

As soon as I corrected that things started working. Thanks all for helping out, sorry it wasn't anything more exciting, I'll try to produce a more exotic problem next time. ;)
 
Upvote 0
Top