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.
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.
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
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