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

Thanks,
Justin Anderson
MagouyaWare Developer
 http://sites.google.com/site/magouyaware 






-- 



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. HOWTO: run a particular CTS test with DDMS?

I'm running into a CTS exception and would like to take a close look
at the particular test/failure using DDMS. Is it possible to run CTS
with DDMS? Alternatively... I can install the CTS test .apk file...
but how do I then invoke the particular test?

Thank you,
Bruce

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. creating and opening sqlitedb on sdcard for api7

Make sure you have the WRITE_EXTERNAL_STORAGE permission. Also, in the
stack trace you listed, there is probably a "Caused by:" section after
what you had in your original email -- that may give you additional
clues.




-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.1
Available!

-- 

3. xml parsing

4. Google should clearly express their marketing strategy regarding Android Market

5. IllegalArgumentException when trying to run an OpenGL ES 2.0 application

6. Any Tree (Swing/JTree-like) widget for Android?

7. <AbsoluteLayout>