help please !!!!!!!!!

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Mar 15, 2016 11:28:09 AM via Website

i have a problem with detecting a swipe
i'm working on a calculator using visual studio and i want to give the user the ability to change
between activity using a swipe
here is the code

    public override bool OnTouchEvent(MotionEvent e)
        int action = (int)e.Action;

        switch (action)
            case (int)MotionEventActions.Down:

                x1 = e.GetX();
                y1 = e.GetY();

            case (int)MotionEventActions.Up:

                x2 = e.GetX();
                y2 = e.GetY();
        if (x1 < x2)



        return true;

it works fine on the text view but when i swipe over the buttons
it doesn't work

hope someone could help me out and thanks in advance

  • Forum posts: 13

Mar 15, 2016 2:42:22 PM via Website

Probably button handle onTouch. In my opinion, you should use:


in MotionEvent.ACTION_DOWN,

and calls performClick() in MotionEvent.ACTION_UP

performClick should be override similar as below:

public boolean performClick() {
    // Handle the action for the custom click here
    return true;