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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:23:19+00:00 2026-06-11T13:23:19+00:00

I am having a strange behavior with threads and a `onclick listener instance in

  • 0

I am having a strange behavior with threads and a `onclick listener instance in some phones (strange that its not by android version, have test it in a GalaxyII with android 4.03 and work, in a Samsumg Galaxy Tab with 3.2 works fine and in a HTC EVO Design 4G with android 4.03 and a HTC EVO 4G with android 2.3.3 doesn’t work) so here is the issue:

I have a async class that calls a web service and blocks the screen until the service finishes, then the thread notifies the UI that the service call is finished so the UI shows a modal screen making a addView(GenerateView) to the activity. That works fine until I need to avoid the multiple clicks in the button that triggers the action because multiple views are adding to the activity. So I implement a custom OnClickListener like this:

public abstract class OnOneClickListener implements OnClickListener {
    private boolean clickable;

    public OnOneClickListener(){
        clickable = true;
    }

   public final void onClick(View v) {
       if (clickable) {
           clickable = false;
           onOneClick(v);
       }
   }

   public abstract void onOneClick(View v);

   public void reset() {
       clickable = true;
   }
}

So I implement the custom onclick, block the clickabilty of the button, call the web service and when it finishes in the function that creates and returns the view to add to the activity as a modal windows calls reset() and allows the click in button again. That function receives the instance of the class by parameters. That works like a charm in the phone that mentioned before but in the HTCs when i debug can see that the OnOneClickListener() function modify the clickable variable and the reset() function doesn’t see it!! and it happens in the other way too, like if the call of the functions where in two different instances of the class and it NOT!! and thats just one issue that im having with HTCs and threads, the most incredible one.

So here goes my questions:

  • Is some knowed issues with HTCs and threads??
  • Is there some work around?? (Im using AsyncTask to make the calls and it works perfect until now)

In fact anything that you can tell me that help me understand where is the fail will be very helpful because it’s driving me crazy.

  • 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-11T13:23:20+00:00Added an answer on June 11, 2026 at 1:23 pm

    You’re lucky it works on some phones, because it does not have to. If you change clickable field on one thread, you should explicitly synchronize for the other thread to see the changes.

    Try making clickable field volatile. Jeremy Manson has a great article about volatile and other good Java concurrency articles.

    I also suggest you to implement what you want the other way – just make the button disabled on first click until your web service gives you a result. Disabled button is a clear message to user that you handled the click and are doing something while it is disabled.

    Check also Happened-before term on Wikipedia.

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

Sidebar

Related Questions

We have an iOS application for the iPad that is having strange behavior. We
Having some strange behavior here. I have some XSLT which generates some html with
i'm having strange behavior from the for loop in python. The problem is not
I'm having some strange behavior where my MPMoviePlayerViewController isn't auto -rotating when the orientation
I'm having quite a difficulty, figuring out some strange behavior when looping through symbols
I have strange behavior with android.R.layout.simple_dropdown_item_1line while using MultiAutoCompleteTextView . The code I use
I'm having some strange behaviour. If the database does not exists, and i execute
I am having some very strange behavior when using a set (it's actual a
I am having some very strange ListView behavior when using a StateListDrawable as the
I'm having a strange behavior with an operator overloading in C++. I have a

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.