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. AAPT usage different between 1.1 and 1.5

Hello there,

I used an build.xml file for building projects with ant with 1.1 sdk.
When wanted to switch to 1.5_1 or 1.5_3 SDK, the aapt located now
under platforms\android-1.5\tools is not working with the build.xml.

The target for aapt is:

<exec executable="${aapt}" failonerror="true">
            <arg value="package" />
            <arg value="-f" />
            <arg value="-M" />
            <arg value="AndroidManifest.xml" />
            <arg value="-S" />
            <arg value="${resource-dir}" />
            <arg value="-A" />
            <arg value="${asset-dir}" />
            <arg value="-I" />
            <arg value="${android-jar}" />
            <arg value="-F" />
            <arg value="${resources-package}" />

This one worked and still works perfectly with the aapt under 1.1 sdk,
but not with the aapt under 1.5 sdk.
The error message i receive is,

[exec] ERROR: failed opening/creating 'res/raw/whatever.mp3' as Zip

I do have an mp3 file in the res\raw folder as instructed by the docs,
and the same project structure builds fine under eclipse.
Unfortunately, with ant it doesn't.

Also noticed that, even if another aaps file is in the platform
\android1.1\tools directory in 1.5 sdk, that file is different from
the one included in \tools under 1.1 sdk, and it's giving the same
error message.

Can someone help me out with this?

Thank you in advance


2. What is CONTENT_STREQUENT_URI used for ?

I'm looking at CONTENT_STREQUENT_URI, desribed as 'only starred
contacts and the most frequently contacted contacts'.

When we show a contact group picker, we could include this as a sort
of meta-group. It seems like a very useful thing.

But I'd like our picking to be familiar to the user, so I have gone
looking for other apps using this on the emulator, so I know what to
call it. I can't find any.

Does anyone know where it is used, or planned to be used ?




3. Will V8 be used in Android 2.0

4. Wish Google's to provide unicode for myanmar language in DroidSerif-Regular.ttf

5. How to call Mediaframework testcases from my Java application

6. There's no unicode support .ttf for south east asia language in Android

7. Possible to rescan sd-card with Media Scanner?