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. Filter-Search Applications

Hi,

I try to add filter search to my application, query search works fine.
I can type in a search term press enter and the result is presented.
However, I don't get a new intent when I change the search term.

(from doc of SearchManager: You will receive a new ACTION_SEARCH
Intent each time the user enters or changes the search text. You must
receive and handle these new intents by overriding onNewIntent.)

I added the filterMode bit but nothing happens. What else do I have to
do in order to enable filter search?

Here is my
search xml:

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
     android:label="@string/app_name"
     android:hint="@string/searchhint"
     android:icon="@drawable/application001a"
     android:searchMode="filterMode|filterModeQuickStart|
showSearchLabelAsBadge">
 </searchable>


and the manifest xml:

<activity android:name=".MainActivity"
                                        android:label="@string/app_name"
                                        android:icon="@drawable/application001a"
                >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="org.openintents.category.MAIN" />
            </intent-filter>

            <intent-filter>
                                <action 
android:name="android.intent.action.SEARCH" />
                                <category 
android:name="android.intent.category.DEFAULT" />
                        </intent-filter>
                        <meta-data android:name="android.app.searchable"
                                android:resource="@xml/searchable" />
        </activity>


Cheers,
Friedger
--~--~---------~--~----~------------~-------~--~----~

2. Does Android support the arm9-linux?

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~

3. How to change data in emulator, which is set in android:label in AndroidManifest.xml file.

4. create map

5. How to change data in emulator, which is set in android:label in AndroidManifest.xml file.

6. :textAlign

7. How to change icon in Alert Dialog box?