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 4007528
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:38:35+00:00 2026-05-20T08:38:35+00:00

I asked a similar question in the android developers group but haven’t received a

  • 0

I asked a similar question in the android developers group but haven’t received a response yet, so I figured I’d try my luck here.

I want to implement a vertical swipe on a Gallery and I have it working… sort of. I subclassed Gallery so that I could override the onFling and onDown methods.

Here is the code I used to override these methods:

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
    if (m_curTouchPos == NO_CURRENT_TOUCH_POS || m_callback == null)
        return super.onFling(e1, e2, velocityX, velocityY);

    float e1x = e1.getX();
    float e1y = e1.getY();
    float e2x = e2.getX();
    float e2y = e2.getY();

    float offPath = Math.abs(e1x - e2x);
    float distance = Math.abs(e1y - e2y);

    if (offPath < s_swipeMaxOffPath && 
        //Math.abs(velocityY) >= s_swipeMinVelocity && 
        distance >= s_swipeMinDistance)
    {
        if (e1y > e2y)
        {
            m_callback.onSwipeUp(m_curTouchPos);
            //return true;
        }
        else if (e2y > e1y)
        {
            //TODO: IMPLEMENT THIS
            //m_callback.onSwipeDown(m_curTouchPos);
            //return true;
        }
    }

    m_curTouchPos = NO_CURRENT_TOUCH_POS;
    return super.onFling(e1, e2, velocityX, velocityY);
}

@Override
public boolean onDown(MotionEvent eve)
{
    m_curTouchPos = pointToPosition((int)eve.getX(), (int)eve.getY());
    return super.onDown(eve);
}

The problem is that onFling doesn’t get called when I do a vertical swipe… In order to get into the onFling method I have to press on an item in the gallery, slide it slowly a little to the left or right, and then swipe vertically.

Horizontal swipes always get into the onFling method.

Any ideas on how to get this to work?

  • 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-20T08:38:36+00:00Added an answer on May 20, 2026 at 8:38 am

    Ok, I have found the answer… The onDown() method needs to return true. The call to return super.onDown(eve) was causing it to fail because the default implementation returns false.

    I found the answer in another post here on StackOverflow:

    Android: GestureDetector not working (gestureDetector.onTouchEvent(event) always false) with Tabs (TabActivity, Tabwidget)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked a similar question the other day but wasn't satisfied with the response,
Question 828421 asked similar question, but received only one real answer (update rubygems) and
Somebody asked similar question not long ago. But nobody answered comprehensively. Assume I have:
I asked a similar question before, but it was answered inadequately so I thought
I asked a similar question in Code Review forum but was suggested to ask
I asked a similar question yesterday, but recognize that i need to rephase it
I asked a similar question earlier, but posed it as a language-specific question. I
I asked a similar question a couple of days ago, but I'm looking for
I asked a similar question previously, but it was so vague that I couldn't
I asked a similar question, but I couldn't get it working exactly. I'm building

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.