0

I'm trying to disable swipe in certain direction in my viewpager using Xamarin. So I define a custom viewPager and override OnInterceptTouchEvent method to check gesture direction.

My problem is that my case MotionEventActions.Move is never fired, while MotionEventActions.Down. I have already check return and try different (return true or false in MotionEventActions.Down case, but without any results.

public override bool OnInterceptTouchEvent (MotionEvent ev)
        {
            if (Enabled) {  
                switch (ev.Action) {
                    case MotionEventActions.Move:                   
                        if (lastX > ev.GetX ()) {
                            // Swipe right to left
                            swipeLeft = true;
                            swipeRight = false;
                        } else {
                            // Swipe left to right
                            swipeLeft = false;
                            swipeRight = true;
                        }
                        lastX = ev.GetX ();
                        break;

                    case MotionEventActions.Down:
                        lastX = ev.GetX ();
                        break;                  
                }

                lastX = ev.GetX();

                /*
                // Swipe right to left enable
                if(EnabledLeft) {
                    return true;
                } 
                // Swipe left to right enable
                if(EnabledRight) {
                    return true;
                } else {
                    return false;
                }   
                */          
            }
            return false;
        }

I just want to fire this case in order to update my lastX variable...

TGuerin
  • 345
  • 3
  • 18
  • I think you need to use MotionEvent.ACTION_MOVE instead of MotionEventActions.Move – VVB Oct 28 '15 at 11:59
  • I'm using Xamarin and there is no MotionEvent.ACTION_MOVE. A Xamarin example use the same... Thanks you – TGuerin Oct 28 '15 at 13:01

0 Answers0