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

  • Home
  • SEARCH
  • 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 8452973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:38:47+00:00 2026-06-10T11:38:47+00:00

I want to connect long press with scroll, so the user doesn’t have to

  • 0

I want to “connect” long press with scroll, so the user doesn’t have to release the screen and start to scroll.

I have gesture detector implemented…

final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
    public void onLongPress(MotionEvent e) {
        // action 1
    }

    public boolean onScroll(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {
        // action 2
    }       
}

public boolean onTouchEvent(MotionEvent event) {
    return gestureDetector.onTouchEvent(event);
}    

But now between action 1 and action 2, user have to release the screen… How can I connect this actions without releasing the screen??

  • 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-10T11:38:48+00:00Added an answer on June 10, 2026 at 11:38 am

    I don’t think a GestureDetector will do what you want, more likely you’ll have to do it yourself. I don’t know your current setup, below is a class with a OnToucListener tied to a ScrollView which will take in consideration both events:

    public class ScrollTouchTest extends Activity {
    
        private final int LONG_PRESS_TIMEOUT = ViewConfiguration
                .getLongPressTimeout();
        private Handler mHandler = new Handler();
        private boolean mIsLongPress = false;
        private Runnable longPress = new Runnable() {
    
            @Override
            public void run() {         
                if (mIsLongPress) {             
                    actionOne();
                    mIsLongPress = false;
                }
            }
    
        };
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.views_scrolltouchtest);
            findViewById(R.id.scrollView1).setOnTouchListener(
                    new OnTouchListener() {
    
                        @Override
                        public boolean onTouch(View v, MotionEvent event) {
                            final int action = event.getAction();
                            switch (action) {
                            case MotionEvent.ACTION_DOWN:
                                mIsLongPress = true;                            
                                mHandler.postDelayed(longPress, LONG_PRESS_TIMEOUT);
                                break;
                            case MotionEvent.ACTION_MOVE:
                                actionTwo(event.getX(), event.getY());
                                break;
                            case MotionEvent.ACTION_CANCEL:
                            case MotionEvent.ACTION_UP:
                                mIsLongPress = false;
                                mHandler.removeCallbacks(longPress);
                                break;
                            }
                            return false;
                        }
                    });
        }
    
        private void actionOne() {
            Log.e("XXX", "Long press!!!");
        }
    
        private void actionTwo(float f, float g) {
            Log.e("XXX", "Scrolling for X : " + f + " Y : " + g);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to connect my log4j.xml with log4j.xsd (xml schema). Project don't have any
I want to connect my rails 3 application to firebird database. I have followed
I'm working on application and I want to connect it to facebook. The user
I have 2 tables I want to connect in a strange / dangerous /
I want to connect a single ForeignKey to two different models. For example: I
I want to connect from home using SQL Server 2005 to another PC. I
I want to connect to DB2 from excel macro...This is my code, but it
I want to connect to a URL with the socket method ( http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=VS.96).aspx );
i want to connect database to iphone sdk but it is taking the default
In my application I want to connect SQL Server Express with Hibernate. But I

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.