Android Question B4XPages handling event clicks

tsteward

Well-Known Member
Licensed User
Longtime User
I have a CLV with 4 buttons on each row.
All buttons cal the same sub

What is the appropriate way to define the sub so it works for B4A & B4J
At the moment I have this but feel there is a better way.
B4X:
#if b4a
Private Sub iv1_Click
#else B4J
Private Sub iv1_MouseClicked (EventData As MouseEvent)
#end if
    Dim tempiv As B4XView = Sender
    Main.currentMakeID = tempiv.Tag
    B4XPages.ShowPage("model page")
End Sub
 

josejad

Expert
Licensed User
Longtime User
Hi:

I think you're using the right way, from this Erel's example, where you can learn a lot of things, this is the way he does: (this way is compatible with B4i too)

B4X:
#if B4J
Private Sub iv1_MouseClicked (EventData As MouseEvent)
#else
Private Sub  iv1_Click
#end if
   Dim tempiv As B4XView = Sender
    Main.currentMakeID = tempiv.Tag
    B4XPages.ShowPage("model page")

End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Have you tried to use just this code?

B4X:
Private Sub iv1_Click
    Dim tempiv As B4XView = Sender
    Main.currentMakeID = tempiv.Tag
    B4XPages.ShowPage("model page")
End Sub

In B4J Buttons have also the Click event.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
Have you tried to use just this code?

B4X:
Private Sub iv1_Click
    Dim tempiv As B4XView = Sender
    Main.currentMakeID = tempiv.Tag
    B4XPages.ShowPage("model page")
End Sub

In B4J Buttons have also the Click event.
Yeah tried that but the event never fires in B4J
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
Are you iv1 objects Buttons or ImageViews?
I tested Button_Click in B4J before sending my previous post, and it works.
Only Buttons have a Click event in B4J.
Sorry mine is an image view
 
Upvote 0
Top