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. So can we use Directions API or not in Android?

I would love to be able to use the Directions API in my Android app,
but I'm confused by the information in the Directions API
documentation: http://code.google.com/apis/maps/documentation/directions/
so the short form of my question is: can Android apps use the Google
Directions API?

It clearly states the intended audience includes mobile developers.
But it also states that you're limited to 2500 requests per day. Does
this mean my app, if deployed to thousands of devices, is in total
restricted to 2500 requests per day? How could the Google server tell
anyway? Based on IP address? In which case I may be okay. The docs
also say no API key is required so again it would seem the Google
servers have nothing to use to accumulate a counter of requests per
day. Still, I don't want to be in violation of any Google Terms of

So is it okay or not? Thanks in advance.

- dave


2. Odd size Dell Aero screen: 360x640 px

Dell's first US released smart phone was released today. It has this
odd sized screen of 360x640px. I really wonder what that's going to
look like with the average app?

On the plus side, it's light and inexpensive ($300 without contract).

On the negative side it's on AT&T, has a miniscule battery (1000 mAh),
slow processor (624 MHz) and runs Cupcake (1.5) of all things.

Maybe Dell can do better next time.

-John Coryat


3. Native crash (SIGSEGV) in open gl texture load

4. Using HttpClient

5. avira premium security 2010

6. Maybe you can use this

7. get files under certain directory