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. Help in ViewGroup

hi all..
i have a view group and have added set of views on to it. To the same view
group
i try to add a linear layout which consists of two linear layouts with in
it...
when i do so my added view does not contain any of the child views.. its
blank..
why is it..??
kindly help
thanks in advance..

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

2. Error : Unknown URI: content://media/external/images/media

Hi

Why I have this error, please ? It' s the same java code than the
following url:

http://developer.android.com/intl/fr/guide/topics/providers/content-providers.html


/
****************************************************************************/

package dany.android.databasejpeg;

import java.io.OutputStream;

import android.app.Activity;
import android.content.ContentValues;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore.Images.Media;
import android.util.Log;

public class testjpeg extends Activity {
    private static final String TAG = null;

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

     // Save the name and description of an image in a ContentValues
map.
        ContentValues values = new ContentValues(3);
        values.put(Media.DISPLAY_NAME, "road_trip_1");
        values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");
        values.put(Media.MIME_TYPE, "image/jpeg");

        // Add a new record without the bitmap, but with the values
just set.
        // insert() returns the URI of the new record.

        Log.v(TAG, Media.EXTERNAL_CONTENT_URI.toString());

        Uri uri = getContentResolver().insert
(Media.EXTERNAL_CONTENT_URI, values);

        // Now get a handle to the file for that record, and save the
data into it.
        // Here, sourceBitmap is a Bitmap object representing the file
to save to the database.

        Bitmap sourceBitmap = BitmapFactory.decodeResource(getResources
(), R.drawable.test);

        try {
            OutputStream outStream = getContentResolver
().openOutputStream(uri);
            sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50,
outStream);
            outStream.close();
        } catch (Exception e) {
            Log.e(TAG, "exception while writing image: ", e);
        }
    }
}
/
****************************************************************************/



08-25 07:08:09.507: ERROR/DatabaseUtils(656): Writing exception to
parcel
08-25 07:08:09.507: ERROR/DatabaseUtils(656):
java.lang.UnsupportedOperationException: Unknown URI:
content://media/external/images/media
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
com.android.providers.media.MediaProvider.insertInternal
(MediaProvider.java:1139)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
com.android.providers.media.MediaProvider.insert(MediaProvider.java:
1118)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
android.content.ContentProvider$Transport.insert(ContentProvider.java:
140)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
android.content.ContentProviderNative.onTransact
(ContentProviderNative.java:125)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
android.os.Binder.execTransact(Binder.java:287)
08-25 07:08:09.507: ERROR/DatabaseUtils(656):     at
dalvik.system.NativeStart.run(Native Method)
08-25 07:08:09.536: DEBUG/AndroidRuntime(735): Shutting down VM
08-25 07:08:09.536: WARN/dalvikvm(735): threadid=3: thread exiting
with uncaught exception (group=0x4000fe70)
08-25 07:08:09.536: ERROR/AndroidRuntime(735): Uncaught handler:
thread main exiting due to uncaught exception
08-25 07:08:09.546: ERROR/AndroidRuntime(735):
java.lang.RuntimeException: Unable to start activity ComponentInfo
{dany.android.databasejpeg/dany.android.databasejpeg.testjpeg}:
java.lang.UnsupportedOperationException: Unknown URI:
content://media/external/images/media
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2268)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.os.Handler.dispatchMessage(Handler.java:99)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.os.Looper.loop(Looper.java:123)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
java.lang.reflect.Method.invokeNative(Native Method)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
java.lang.reflect.Method.invoke(Method.java:521)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
dalvik.system.NativeStart.main(Native Method)
08-25 07:08:09.546: ERROR/AndroidRuntime(735): Caused by:
java.lang.UnsupportedOperationException: Unknown URI:
content://media/external/images/media
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.database.DatabaseUtils.readExceptionFromParcel
(DatabaseUtils.java:131)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.database.DatabaseUtils.readExceptionFromParcel
(DatabaseUtils.java:111)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.content.ContentProviderProxy.insert(ContentProviderNative.java:
340)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.content.ContentResolver.insert(ContentResolver.java:476)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
dany.android.databasejpeg.testjpeg.onCreate(testjpeg.java:34)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
08-25 07:08:09.546: ERROR/AndroidRuntime(735):     ... 11 more


I think is not a problem of permission it's why i dont use permission
into my androidmanifest.xml

Or maybe i have to use :

 <uses-permission
android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>

or an other so what permission i have to use ??

Dany


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

3. which algorithm is fast for Cipher encryption and decryption?

4. Activate GPS service

5. Low Memory: No more background processes.

6. ADC2 Challenge

7. CTS fails for java.io.OutputStreamWriterTest