Disable Button after click

by pabbot » Sat, 12 Mar 2011 02:54:05 GMT

Sponsored Links
 Hi all,

In my application, when I click on a button that inserts a record on
the database and closes the Activity, sometimes it takes long to close
that Activity and some users are clicking on the Button twice. That
causes that the record is inserted twice in the database.

Is there any way of avoiding this behavior?

Thanks in advance!


Re: Disable Button after click

by Cliff Davies » Sat, 12 Mar 2011 02:58:53 GMT

 Set a boolean variable when the button has been pressed and check the
boolean is false in the on click listener so that you don't process it once
it's already been clicked


Sponsored Links

Re: Disable Button after click

by TreKing » Sat, 12 Mar 2011 03:03:36 GMT


Just disable the button when it's clicked, especially if you're closing the
Activity anyway.

TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices


Re: Disable Button after click

by Justin Anderson » Sat, 12 Mar 2011 03:07:01 GMT

 *> Is there any way of avoiding this behavior?*

Yes. Disable the button.
 http://developer.android.com/reference/android/widget/TextView.html #setEnabled%28boolean%29

Justin Anderson
MagouyaWare Developer


Re: Disable Button after click

by Sourav Howlader » Sat, 12 Mar 2011 04:24:01 GMT

 As soon as the button is clicked, set  button.setEnable(false);
  This will disable the button and will avoid from double clicking it.


Other Threads

1. AVD suddenly can't reach the internet

My AVDs suddenly can't reach the internet. I'm testing using the
browser of the AVD. I haven't changed anything that I think is related
on my development machine and I can still reach the internet from the
development machine. I'm sort of at a loss figuring out how to start
debugging this. Is it possible that my ISP is blocking the AVD? Is
there anything different about the HTTP traffic that originates on the
AVD that my ISP might key on?


2. Icecast client, what's the best approach?

Hi all,
I'm in the process of starting a client for a webradio which streams
CC contents (hosted at www.gnufunk.org).

Its stream is Icecast based, and I have actually created a dumb client
by using MediaPlayer on Froyo.

MediaPlayer supports this format, but apparently there's no way of
getting the metadata embedded into the stream (OnInfoListener is never
Because of this behavior I'm wondering wether it'll be a good idea to
use MediaPlayer together with a custom layer that will parse the
stream before
sending it to MediaPlayer itself or rather go the NDK way, porting
libshout (I've have already a stripped down version built for android)
to Android and
use it through jni.
In any cases the application will be released with an Open Source
license (either GPL or Apache 2.0).

Is there a recommended way?
Is there any official support to Icecast / Shoutcast metadata in
Android's builtin classes?
Has anyone already created an Icecast client on Android who is willing
to share about his experience?

Thanks in advance,


3. unable to dismiss a progress dialog

4. Tomcat on Android

5. Need indocomtech Info---

6. how to use javax.com api!

7. OOT/WTI: Lokasi Pengungsian selain Stadion Maguwoharjo