0

How can I detect if the user did only tap and NOT swipe the ViewPager?

When I use OnTouchListener, I can never "just" touch or swipe. A Move event is always preceded by an Up / Down event.

This code always shows me the Toast, no matter if I just tap or swipe:

public class CardPicker : Fragment, View.IOnTouchListener
{
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.Cardpicker, container, false);

            _cardPicker = view.FindViewById<ViewPager>
            _cardPicker.SetOnTouchListener(this);

            return view;
        }

        public bool OnTouch(View v, MotionEvent e)
        {
            if (e.Action == MotionEventActions.Down)
            {
                Toast.MakeText(Context,"Starting an Activity!", ToastLength.Short).Show();
                return true;
            }
            return false;
        }
}
  • I recommened that you look at this post https://stackoverflow.com/questions/4139288/android-how-to-handle-right-to-left-swipe-gestures – 2hTu2 Nov 19 '17 at 20:15
  • You could refer to : https://stackoverflow.com/questions/46073827/xamarin-android-eggstogo-swipe-gesture-listener-in-view-doesnt-work-with-listv/46089669#46089669 – York Shen Nov 21 '17 at 05:07

0 Answers0