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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:48:40+00:00 2026-06-05T21:48:40+00:00

I set up event listener, for example: setOnClickListener like this Button stopBtn = (Button)findViewById(R.id.stop);

  • 0

I set up event listener, for example: setOnClickListener like this

    Button stopBtn = (Button)findViewById(R.id.stop);
    stopBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            doMagic();
        }
    });

I would like to set this listener a timeout event on 10s if button is not pressed. Use case: i have button1 that activates this stopBtn listener for 10s and if timeout comes it becomes deactivated and i need to press button1 to make stopBtn active again.

Im probably doing it wrong:

    final Handler myHandler = new Handler();
    startBtn = (Button)findViewById(R.id.start);
    myHandler.postDelayed(new Runnable() {
        public void run() {
            startBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.i(TAG,"runned");
                }
            });
        }
    }, 10000);

After 10s im still able to click it and that is probably cos event listener is still attached. How can i detach it even if i don’t know if its fired or not.

  • 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-05T21:48:42+00:00Added an answer on June 5, 2026 at 9:48 pm

    A delayed Runnable posted on a Handler could manage that:

    myHandler.postDelayed(new Runnable() {
     public void run() {
       if(something happened) {
         // magic work
       } else {
         // turn off the event
       }
     }
    , 10000);
    

    You can init the Handler as an instance variable by using this code:

    final Handler myHandler = new Handler();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to set a bean property from jsf page before executing this f:event listener:
How can you set the event listener for a Spinner when the selected item
I can set the event on the calendar on my device by using this
I have a draggable event set up like such: $(ids.label).draggable({ containment: ids.wrapper, revertDuration: 100,
I'm a newbie in events. This example shows that an event is invoked every
For example, the following MXML script attaches a listener to a Button class: <mx:Button
import threading event = threading.Event() event.set() print event.wait(1) None event.clear() print event.wait(1) None So
How can I set an event handler (such as keydown ) to entire solution,
is it safe to set an event handler (or delegate) AFTER an asynchronous method
I have a TextBox that has the TextChanged event set declaratively. In some cases,

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.