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. Use 3G and WIFI simultaneously

Hello,

I am working on porting an application (currently native) that
requires both a 3G and WLAN connection. However, I have not been able
to figure out how to keep both active, when I for example connect to a
WLAN the 3G is shut down. Since the OS/Phones support Tethering, I am
guessing it is possible to use both simultaneously, so I am wondering
if anyone has any tips on how to enable it/force both interfaces to
remain active? We are currently working on a Nexus One.

Thanks in advance,
Kristian

-- 

2. Sipdroid crash on InCallScreen with FileNotFoundException

Hello,

im working on a project to get android 2.1 working on a siemens ip
phone with mips cpu.
Further step is to do a sip call with an other sip client, maybe a
cell phone.
Android is working fine...but Sipdroid is not!

If i press the dailing button, Sipdroid wants to switch to the
InCallScreen and crashes with an FileNotFoundException.
The log says that he cant find a color resource from the android
sources named secondary_text_dark.xml.
If i comment the color part out, he runs in the next
FileNotFoundException with arrow_down_float.png not found.
Like seen in the log below.
All these files which can not be found located in android`s /res/color
or res/drawable-mdpi.

Obviously Sipdroid has problems to find these resource files.
Anybody out there with an idea to fix this problem?

log after pressing dailing button:

I/power   ( 1536): *** set_screen_state 1
D/dalvikvm( 1744): GC freed 3957 objects / 305784 bytes in 480ms I/
ActivityManager( 1536): Starting activity: Intent { flg=0x10000000
cmp=org.sipdroid.sipua/.ui.InCallScreen } W/ResourceType( 1744):
Failure getting entry for 0x7f0200a8 (t=1
e=168) in package 0: 0xffffffb1
D/AndroidRuntime( 1744): Shutting down VM W/dalvikvm( 1744):
threadid=3: thread exiting with uncaught exception
(group=0x2aac2170)
E/AndroidRuntime( 1744): Uncaught handler: thread main exiting due to
uncaught exception E/AndroidRuntime( 1744):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{org.sipdroid.sipua/
org.sipdroid.sipua.ui.InCallScreen}: android.view.InflateException:
Binary XML file line #127: Error inflating class
android.widget.ImageButton
E/AndroidRuntime( 1744):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2496)
E/AndroidRuntime( 1744):        at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2512)
E/AndroidRuntime( 1744):        at android.app.ActivityThread.access
$2200(ActivityThread.java:119)
E/AndroidRuntime( 1744):        at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 1744):        at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1744):        at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime( 1744):        at
android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 1744):        at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1744):        at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1744):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 1744):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 1744):        at
dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 1744):
Caused by: android.view.InflateException:
Binary XML file line #127: Error inflating class
android.widget.ImageButton
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.createView(LayoutInflater.java:513)
E/AndroidRuntime( 1744):        at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:
56)
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.inflate(LayoutInflater.java:407)
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.inflate(LayoutInflater.java:320)
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.inflate(LayoutInflater.java:276)
E/AndroidRuntime( 1744):        at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:
198)
E/AndroidRuntime( 1744):        at
android.app.Activity.setContentView(Activity.java:1622)
E/AndroidRuntime( 1744):        at
org.sipdroid.sipua.ui.InCallScreen.onCreate(InCallScreen.java:352)
E/AndroidRuntime( 1744):        at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
E/AndroidRuntime( 1744):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2459)
E/AndroidRuntime( 1744):        ... 11 more
E/AndroidRuntime( 1744): Caused by:
java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 1744):        at
android.widget.ImageButton.<init>(ImageButton.java:78)
E/AndroidRuntime( 1744):        at
java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 1744):        at
java.lang.reflect.Constructor.newInstance(Constructor.java:446)
E/AndroidRuntime( 1744):        at
android.view.LayoutInflater.createView(LayoutInflater.java:500)
E/AndroidRuntime( 1744):        ... 23 more
E/AndroidRuntime( 1744): Caused by: android.content.res.Resources
$NotFoundException: File res/drawable-mdpi/arrow_down_float.png from
drawable resource ID #0x7f0200a8
E/AndroidRuntime( 1744):        at
android.content.res.Resources.loadDrawable(Resources.java:1710)
E/AndroidRuntime( 1744):        at
android.content.res.TypedArray.getDrawable(TypedArray.java:548)
E/AndroidRuntime( 1744):        at android.view.View.<init>(View.java:
1850)
E/AndroidRuntime( 1744):        at
android.widget.ImageView.<init>(ImageView.java:109)
E/AndroidRuntime( 1744):        at
android.widget.ImageButton.<init>(ImageButton.java:82)
E/AndroidRuntime( 1744):        ... 27 more
E/AndroidRuntime( 1744): Caused by: java.io.FileNotFoundException:
res/ drawable-mdpi/arrow_down_float.png
E/AndroidRuntime( 1744):        at
android.content.res.AssetManager.openNonAssetNative(Native Method)
E/AndroidRuntime( 1744):        at
android.content.res.AssetManager.openNonAsset(AssetManager.java:390)
E/AndroidRuntime( 1744):        at
android.content.res.Resources.loadDrawable(Resources.java:1702)
E/AndroidRuntime( 1744):        ... 31 more
I/Process ( 1536): Sending signal. PID: 1744 SIG: 3 I/dalvikvm( 1744):
threadid=7: reacting to signal 3 E/dalvikvm( 1744): Unable to open
stack trace file '/data/anr/
traces.txt': Permission denied
E/ActivityThread( 1536): Failed to find provider info for
android.server.checkin E/Checkin ( 1536): Error reporting crash:
java.lang.IllegalArgumentException: Unknown URL 
content://android.server.checkin/crashes



Thanks for your help

Bastian

P.S. phone is running on 640x480

-- 

3. Problem with rotated preview of camera in Nexus android 2.2

4. How to send sms when debug in a real phone?

5. Weird problem with ListView

6. Adding new feature in address book/ modifying the existing address book

7. locale change does not affect menu