Android Question Responding to Touch event within a class module

Andrew Gray

Member
Licensed User
Longtime User
Hi,

I need to handle a Panel Touch event within a class module, but Activity.ACTIVITY_DOWN, Activity.ACTION_MOVE and Activity.ACTION_UP don't work here.

The values of these don't seem to be documented anywhere, but they appear to be 0 for down, 2 for move and 1 for up. Can I just hard-code these three constants into my class module? i.e. instead of testing if Action = Activity.ACTION_DOWN, test if Action = 0, etc.

Or is there a better way of doing this?

Andrew
 

Jaames

Active Member
Licensed User
Longtime User
Of course you can. Those are int constant values.

But if you want you can define within the Class_Globals sub your own constant values, which are the same
as the standard values.
B4X:
Sub Class_Globals
    Dim Const ACTION_DOWN As Int  = 0
    Dim Const ACTION_UP As Int = 1
    Dim Const ACTION_MOVE As Int = 2
...

The code is then much easier to read...
 
Last edited:
Upvote 0
Top