Android Question Swipe Up and Down Events

GeoffT660

Active Member
Licensed User
Longtime User
Is it possible to detect the swipe up and down event in an Activity. I would like to implement a move next record/move previous record but am not sure how to capture these events.
 

Brandsum

Well-Known Member
Licensed User
Here is the solution without any library:

B4X:
Sub Globals
    Dim MOVEMENT_THRESHOLD As Int = 200dip
    Dim StartY As Int
End Sub

Sub Swipe(Down As Boolean)
    If Down Then
        Log("Down")
    Else
        Log("Up")
    End If
End Sub

Sub Activity_Touch (Action As Int, X As Float, Y As Float)
    Select Action
        Case Activity.ACTION_DOWN
            StartY = Y
        Case Activity.ACTION_UP
            If Abs(Y - StartY) > MOVEMENT_THRESHOLD Then
                Swipe(Y > StartY)
            End If
    End Select
    Return True
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…