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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:47:35+00:00 2026-06-03T14:47:35+00:00

In android, How can I repeat calls a function from the time user press

  • 0

In android,

How can I repeat calls a function from the time user press a button until he/she release that button?

I have check clickListener and longclicklistener, but it does not seem like they do what I want.

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-06-03T14:47:37+00:00Added an answer on June 3, 2026 at 2:47 pm

    You can use OnTouchListener:

    public class MainActivity extends Activity implements OnTouchListener
    {
    
        private Button button;
    
        // ...
    
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            // ...
    
            button = (Button) findViewById(R.id.button_id);
            button.setOnTouchListener(this);
    
            // ...
        }
    
        // ...
    
        @Override
        public boolean onTouch(View v, MotionEvent event)
        {
            /* get a reference to the button that is being touched */
            Button b = (Button) v;
    
            /* get the action of the touch event */
            int action = event.getAction();
    
            if(action == MotionEvent.ACTION_DOWN)
            {
                /*
                    A pressed gesture has started, the motion contains
                    the initial starting location.
                */
            }
            else if(action == MotionEvent.ACTION_UP)
            {
                /*
                    A pressed gesture has finished, the motion contains
                    the final release location as well as any intermediate
                    points since the last down or move event.
                */
            }
            else if(action == MotionEvent.ACTION_MOVE)
            {
                /*
                    A change has happened during a press gesture (between
                    ACTION_DOWN and ACTION_UP). The motion contains the
                    most recent point, as well as any intermediate points
                    since the last down or move event.
                */
            }
            else if(action == MotionEvent.ACTION_CANCEL)
            {
                /*
                    The current gesture has been aborted. You will not
                    receive any more points in it. You should treat this
                    as an up event, but not perform any action that you
                    normally would.
                */
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that the native Gallery application of Android can display pictures stored from
Can Android OS that is installed on actual devices be emulated in VMWare or
In the android we can see that there is a default google search on
I'm looking for a java library that works on the android that can download
Android comes with lots of system resources ( android.R ) that can be used
On many Android devices you can get into a secret settings menu from Phone
I have some doubts regarding In-Application-Billing in android: Can i test it with different
I have a series of OpenGL-ES calls that properly render a triangle and texture
I have an android application in which I take a photo.For that I'm building
I'm experimenting with ORMLite for android. I have a pre built SQLite db that

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.