Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4536202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:30:14+00:00 2026-05-21T14:30:14+00:00

im having an application which needs onTouch swipe events like in Iphone. they are

  • 0

im having an application which needs onTouch swipe events like in Iphone. they are

  1. Swipe Up.
  2. Swipe Down.
  3. Swipe Left.
  4. Swipe Right.

i implemented onTouch event as following . and i got Swipe Left and Right actions correctly.but which is the correct way to implement the swipe Down and Up actions.

MYCODE:

    float downXValue,downYValue;

    @Override
    public boolean onTouchEvent(MotionEvent arg1) {

         // Get the action that was done on this touch event
        switch (arg1.getAction())
        {
            case MotionEvent.ACTION_DOWN:
            {
                // store the X value when the user's finger was pressed down
                downXValue = arg1.getX();
                downYValue = arg1.getY();
                break;
            }

            case MotionEvent.ACTION_UP:
            {
                // Get the X value when the user released his/her finger
                float currentX = arg1.getX();   
                float currentY=arg1.getY();

                // going backwards: pushing stuff to the right
                if (downXValue < currentX)
                {
                    Log.d(DEBUG_TAG, "Right");
                }

                // going forwards: pushing stuff to the left
                if (downXValue > currentX)
                {

                    Log.d(DEBUG_TAG, "Left");
                }
                break;
            }
        }

         //GestureListener is called here... 

        //return gestures.onTouchEvent(event);


        return true;
    }

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:30:15+00:00Added an answer on May 21, 2026 at 2:30 pm

    What about…

    if (downYValue < currentY)
    {
        Log.d(DEBUG_TAG, "Down");
    }
    

    Are you sure you wrote the code above?

    Edit

    OK, I believe you. What you have to do is basically:

    double sizeInX = Math.abs(downXValue - currentX);
    double sizeInY = Math.abs(downYValue - currentY);
    if( sizeInX > sizeInY ){
       // you better swipe horizontally
    } else {
       // you better swipe vertically
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an IPhone application which is having a non consumable in app purchse
I am creating an application for the iPhone which involves having more than one
i am having an application which can share Notes to evernote,it works fine i
I am developing application which is having Gujarati font in text-view but my problem
I'm having a problem compiling an application which uses Core-Plot in debug mode. It
I'm having trouble deploying .NET application which uses Microsoft Access automation. I've installed the
I ran dotTrace on my application (which is having some issues). IntPtr System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr,
I am having one Gtk+ and C application in which i want to set
I have a application in which I am using socket programming , having this(image)
In our application, we are having various windows which contain grid and their respective

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.