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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:38:59+00:00 2026-06-04T12:38:59+00:00

Hi SimpleOnGestureListener dosen’t work in my application this is how I’m implementing it. Maybe

  • 0

Hi SimpleOnGestureListener dosen’t work in my application this is how I’m implementing it. Maybe you can spot what is wrong. The thing is debugging shows the application never goes in to the onFling(…) methode and gdt.onTouchEvent(event); always returns false :/
Any ideas?? Thanks

my activity class

 public class SimpleActivity extends Activity{


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simpleLayout);

    final ImageView imageView = (ImageView) findViewById(R.id.gggbbb);
     imageView.setOnTouchListener(new OnFlingGestureListener() {

        @Override
        public void onTopToBottom() {
           System.out.println("top");
        }

        @Override
        public void onRightToLeft() {
            System.out.println("right");
        }

        @Override
        public void onLeftToRight() {
            System.out.println("left");
        }

        @Override
        public void onBottomToTop() {
            System.out.println("bottom");
        }
     });



}


    }

my abstract Listener

 package com.dmd.client.detailsMenus;

 import android.view.GestureDetector;
 import android.view.GestureDetector.SimpleOnGestureListener;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnTouchListener;

 public abstract class OnFlingGestureListener implements OnTouchListener {

  private final GestureDetector gdt = new GestureDetector(new GestureListener());

  @Override
  public boolean onTouch(final View v, final MotionEvent event) {
     return gdt.onTouchEvent(event);
  }

  private final class GestureListener extends SimpleOnGestureListener {

     private static final int SWIPE_MIN_DISTANCE = 60;
     private static final int SWIPE_THRESHOLD_VELOCITY = 100;

     @Override
     public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
         if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
             onRightToLeft();
             return true;
          } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
             onLeftToRight();
             return true;
          }
          if(e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
             onBottomToTop();
             return true;
          } else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
             onTopToBottom();
             return true;
          }
          return false;
     }
  }

  public abstract void onRightToLeft();

  public abstract void onLeftToRight();

  public abstract void onBottomToTop();

  public abstract void onTopToBottom();

}
  • 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-06-04T12:39:01+00:00Added an answer on June 4, 2026 at 12:39 pm

    Replace this event:

    @Override
    public boolean onTouch(final View v, final MotionEvent event) {
      gdt.onTouchEvent(event);
      return true;
    }
    

    it should work

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

Sidebar

Related Questions

I am implementing a MyGestureDetector that extends a SimpleOnGestureListener. I borrowed the class from:
I made SimpleOnGestureListener capturing onLongPress with MotionEvent, but the problem is that I can't
I am using the onScroll method of GestureDetector.SimpleOnGestureListener to scroll a large bitmap on
Ok, so I have this setup ScrollView HorizontalScrollView ImageView I am trying to capture
I want to get fling gesture detection working in my Android application. What I
I has the following GestureListener: public class BookListener extends SimpleOnGestureListener implements OnTouchListener { private
I have created an Activity that shows a listview and on swipe action another
I'm having problems with memory leaks. When I show an Activity every thing works.
I am working on charts. I can zoom in-out, dragging... Also I need longclick
I have onLongPress and onDoubleTap actions placed on the button according to this code:

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.