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. Bitmap Question

Hello Group,

I was wondering how do you scale a bitmap to look good on any screen size 
(Using surfaceview and canvas). I already know the canvas width and canvas 
height. So, what would the calculation be?

Example lets say I have a picture that is 100x100 and the phone size is 
1920x1200 (just for the sake of it). Now when displaying that on the phone, 
it will look small. So, how do i scale that up to be bigger based on the 
aspect ratio or resolution. Just say the developed phone resolution was 
480x854 (so all pics was created after that res).

So, if the resolution is smaller i want to scale the bitmap down, and if it 
is bigger, i want to scale it up.

Any feedback is appreciated, thanks.


2. Android porting to hawkboard

Hi all,

I am currently working on porting android 1.5 (i.e hawk-donut) onto

The above issue that I am facing right nw is

I do have problem with the input devices (keyboard) interfaced to the
hawkboard .After the  desktop with the sliding screen is displayed.Any key
that u press on the keyboard it launches the default keypad application with
the text box and this application hangs on. Any key pressed on the virtual
key pad is printed on the text box but   ESC/or any key does not terminate
the keypad  application and it continues to be there . Any solution how to
resolve terminate this default application.

Mona Mohan


3. [WTS] Tablet Android Eken M002

4. intents or activities run during app install/uninstall like rpm %post/%postun?

5. Apakah samsung galaxy Samsung I 5503 dpt upgrade dr Ecair ke Froyo ?

6. http pipelining

7. problem in installing android sdk in proxy network