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. Exchange AS support


A lot of corporate users are having difficulty using the device to
sync to Exchange.  I'd like to see if you guys know of any way we can
boil this issue up to the senior developers to get some attention to
the issue.

See below.





2. Need some feedback on my Android application - "aCar"

Hi Guys,

It's a few days I've released my first Android application (aCar) to
Google Android Market under "Productivity" category (for FREE). aCar
is the tool to effectively track the maintenance, fuel mileage and
expenses of your vehicles.

The application contains a quick user guide (accessible from options
menu of main screen) to let you know what you can do next.

Feature List:
    * Tracking gas mileage and vehicle maintenance
    * Multiple vehicles support
    * Powerful searching and filtering
    * Storing vehicle details (VIN, Insurance Policy, License Plate,
Make, Model, etc.)
    * Exposing your data as report sheets and charts (Fuel Efficiency,
Fuel Price, Fuel Expenses, Distance between Fill-Ups, Service
Expenses, Fuel Statistics)
    * Supporting several international units: MPG (US), MPG (Canada),
MPG (Imperial), L/100km, gal/100mi (US), gal/100mi (Imperial), km/L,
km/gal (US), km/gal (Imperial), mi/L
    * Customizable service reminders (both time and mileage based)
    * Supporting several data fields for your fill-up and service
records (Location, Payment Type, Fuel Octane, Fuel Brand, Tags,
Notes), while they can be easily turned off/on to suit your needs

I will appreciate if any of you download and give it a try and let me
know what you think. Whether the quick user guide has enough details
to help you get started, or if the overall user interface of the
application is intuitive and good enough, or how you would like to see
it improved. I need all your feedbacks, comments, complaints,
mentioning of pros and cons, or whatever else you would like to share
about this application, good or bad! All are welcome!

More information about aCar, plus some screen shots:

Thank you,


3. Is Android satisfied hVGA resolution around 3-inch display?

4. Exchange support for "Sent and user-created" sub-folders

5. Android Medical

6. SMS and MMS message expansion

7. ADB: error: insufficient permissions for device