Apr 8, 2020 Replies: 3 To swipe left-right from one activity to another without panels, buttons or tabs. Put this code in each activity to swipe. Code: Sub Globals Dim Xprevious As Float End sub Sub Activity_Resume Xprevious = 0 End Sub Sub Activity_Touch (Action As Int, X As Float, Y As Float) If Action= Activity.ACTION_MOVE Then If Xprevious = 0 Then Xprevious = X End If If Action = Activity.ACTION_UP Then If X > 0 And X - Xprevious > 400 And Xprevious > 0 Then '400 = swipe distance Log("right") StartActivity("Right") Else If X > 0 And X - Xprevious < -400 Then '-400 = swipe distance Log("left") StartActivity("Left") End If End If Xprevious = 0 End If End Sub Click to expand...
To swipe left-right from one activity to another without panels, buttons or tabs. Put this code in each activity to swipe. Code: Sub Globals Dim Xprevious As Float End sub Sub Activity_Resume Xprevious = 0 End Sub Sub Activity_Touch (Action As Int, X As Float, Y As Float) If Action= Activity.ACTION_MOVE Then If Xprevious = 0 Then Xprevious = X End If If Action = Activity.ACTION_UP Then If X > 0 And X - Xprevious > 400 And Xprevious > 0 Then '400 = swipe distance Log("right") StartActivity("Right") Else If X > 0 And X - Xprevious < -400 Then '-400 = swipe distance Log("left") StartActivity("Left") End If End If Xprevious = 0 End If End Sub
peacemaker Expert Licensed User Longtime User Apr 8, 2020 #2 What about situation if Activity contains any other scrolling containers (scrollview)?
W WimS Member Licensed User Longtime User Apr 15, 2020 #3 Won't work on scrollview : event doesn't raise.
aeric Expert Licensed User Longtime User Apr 15, 2020 #4 Found similar solution: Handle swipe left/right event Private minDistance As Int = 150 Private x1,x2 As Float Sub pnlPhoto_Touch (Action As Int, X As Float, Y As Float) Select Action Case 0 x1 = x Case 1 x2 = x Private deltaX = x2 - x1 If Abs(deltaX) > minDistance Then... www.b4x.com I think smaller difference of X value is better (eg. 150) I tried 400, most of time not working.
Found similar solution: Handle swipe left/right event Private minDistance As Int = 150 Private x1,x2 As Float Sub pnlPhoto_Touch (Action As Int, X As Float, Y As Float) Select Action Case 0 x1 = x Case 1 x2 = x Private deltaX = x2 - x1 If Abs(deltaX) > minDistance Then... www.b4x.com I think smaller difference of X value is better (eg. 150) I tried 400, most of time not working.