Sub Globals
Private Button1, Button2 As B4XView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
Private r As Reflector
r.Target = Button1.As(Button)
r.SetOnTouchListener("Button1_Touch")
Dim jo As JavaObject = Button2
Dim e As Object = jo.CreateEvent("android.view.View.OnTouchListener", "Button2", False)
jo.RunMethod("setOnTouchListener", Array As Object(e))
End Sub
Private Sub Button1_Touch(o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = Activity.ACTION_DOWN Then
Button1.Color = xui.Color_Red
Else If ACTION = Activity.ACTION_UP Then
Button1.Color = xui.Color_Blue
End If
Return False
End Sub
Sub Button2_Event (MethodName As String, Args() As Object) As Object
Dim motion As JavaObject = Args(1) 'args(0) is View
' Dim x As Float = motion.RunMethod("getX", Null)
' Dim y As Float = motion.RunMethod("getY", Null)
Dim Action As Int = motion.RunMethod("getAction", Null)
If Action = Activity.ACTION_DOWN Then
Button2.Color = xui.Color_Red
Else If Action = Activity.ACTION_UP Then
Button2.Color = xui.Color_Blue
End If
Return True
End Sub