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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:07:43+00:00 2026-05-26T11:07:43+00:00

In an application I’m working on, I have the requirement that a user must

  • 0

In an application I’m working on, I have the requirement that a user must click & hold a component for a period time before a certain action occurs.

I’m currently using an OnLongClickListener to listen for the longclick, but I find that the length of a click to trigger the OnLongClick event is too short.

For example, let’s say the LongClick event triggers after a 400ms click, but I want the user to have to click & hold for 1200ms before the event triggers.

Is there any way I can configure the LongClick event to require a longer click?
Or is there perhaps another construct that would allow me to listen for longer clicks?

  • 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-26T11:07:43+00:00Added an answer on May 26, 2026 at 11:07 am

    It is not possible to change the timer on the onLongClick event, it is managed by android itself.

    What is possible is to use .setOnTouchListener().

    Then register when the MotionEvent is a ACTION_DOWN.
    Note the current time in a variable.
    Then when a MotionEvent with ACTION_UP is registered and the current_time – actionDown time > 1200 ms then do something.

    so pretty much:

    Button button = new Button();
    long then = 0;
        button.setOnTouchListener(new OnTouchListener() {
    
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_DOWN){
                    then = (Long) System.currentTimeMillis();
                }
                else if(event.getAction() == MotionEvent.ACTION_UP){
                    if(((Long) System.currentTimeMillis() - then) > 1200){
                        return true;
                    }
                }
                return false;
            }
        })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

application design/architecture question for a project that I am building. I have a main
Application use NHibernate. I Have object A that contains set of objects B. I
Application I am working on an MMO and have run into an issue. The
Application : HTA (therefore IE) This is an application that uses SendKeys to populate
An application I have recently started work on has to register two dll's, because
Application : I am working on one mid-large size application which will be used
Application Specific Information: com.oneorangetree.iphoneexample failed to launch in time elapsed total CPU time (seconds):
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
my application use 10 threads that to read a lot of html file.similar the
Application Specific Information: com.my-app failed to launch in time Elapsed total CPU time (seconds):

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.