Android Question I would like to execute my back key code when user swipes from left

CidTek

Active Member
Licensed User
Longtime User
What is the simplest way to implement swipe detection (from left only) in all activities? I want to avoid adding more transparent panels etc that seem to prevail in the samples I have looked at.

I have a well implemented back key handler that decides whether to go back to the previous activity or to remain in the same activity and show the previous panel.

I just want to speed up and simplify the user experience by catching the swipe and calling the sub that handles my back key processing.
 

Shahid Saeed

Active Member
Licensed User
Longtime User
This is how we use the swipe left or right with panels, I am not sure if it can be integrated for activities, but you can give it a try:-

B4X:
Sub Panels_Touch (Action As Int, X As Float, Y As Float)
    Select Action
        Case Activity.ACTION_DOWN
            startX = X
            startY = Y
        Case Activity.ACTION_UP
            If Abs(Y - startY) > 20%y Then Return
            If X - startX > 30%x AND btnRight.Enabled = True Then 
                ChangePanel(False)
            Else If startX - X > 30%x AND btnLeft.Enabled = True Then
                ChangePanel(True)
            End If
    End Select
End Sub
 
Upvote 0

CidTek

Active Member
Licensed User
Longtime User

Unfortunately all my activities contain panels which contain Listviews and it seems Listviews do not absorb touch events.

Replacing my Listviews with custom solutions is not an option at this point.

I think Erel's suggestion of trying Gesture Detector may be my best bet.
 
Upvote 0

Shahid Saeed

Active Member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…