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. alertdialog, under what circumstances will invoking .show directly cause problems?

When creating an AlertDialog...I have noticed in some cases, if you
invoke .show directly, you
get a leaked dialog error when you rotate the phone.
In other cases you don't.

If you don't call .show and use showDialog from the activity you don't
see the leaked dialogs.
Are there some cases when you can use .show?

Or is it just dumb luck if you don't see a problem?

-Mike

2. continuous audio recording in memory

Dear All,

I'm trying to write an App that continuously record audio in memory (in a
circular buffer).

Could anyone point me towards a piece of code (perhaps in the kernel) that
shows how to best to this ?

Thanks,

3. driving a Service through a versioned interface

4. permission enforcement

5. Browser on Android 2.0 does not consider apn proxy anymore

6. WebView does not display normally?

7. A Faster Way to Switch IME...?