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. About Monkey Scripting option

Hi

I would like to tell every body that it is possible to simulate a
sequence of events on emulator using monkey scripting option "-f" .

It is successful on android 2.0 sdk


Regards,
Pradeep

-- 

2. Java Question about reflection

Nothing specifically related to Android: more a java question while
struggling making the switch from objective c to java:

1. In Java static methods when implemented in derived classes are
hidden, not overridden. If I have a method foo() in class A and B.
Execution of: A b = new B(); b.foo() will execute method foo() in
class A. That causes me a problem because if I use factory methods in
classes, for each subclass I need to reimplement the static factory
method. I was wondering how people solved this with or without
reflection (I am okay paying the performance toll at object creation).

2. I am trying to replicate the easy functionality of the
NSClassFromString method. Basically, if I have a string for a full
qualified class name, what is the best way to invoke a static method
with a known signature for that class.

In objective c:

Class foo()
{
        NSString *r = @"Bar";
        Class c = NSClassFromString(r);
        return c;
}

then you can call method sna() on class Bar with [foo() sna:d]

So far in Java using reflection, I came up with this convoluted code
that doesn't replicate the behavior for the parameters for the
function (I pass back the object reference, not the method back,
therefore I also have to pass the parameter to call the method):

static SuperClassOfBar foo(float d) {
        try {
            String r = "Bar";
            Class c = Class.forName("com.example."+r); // Fully
qualified name for class
            Class partypes[] = new Class[1];
            partypes[0] = Float.TYPE;
            Method m = c.getDeclaredMethod("sna", partypes);
            Object arglist[] = new Object[1];
            arglist[0] = d;
            Object o = m.invoke(null, arglist);
            return SuperClassOfBar.class.cast(o);
        } catch (Exception e) {
            return null;
        }

It works but it's heavy and not pretty. I understand that leaving a
dynamic language like objective c , I have to make some compromises,
but I may miss something about Java for not having found something
more lightweight for such a generic programming functionality. Any
suggestions to simplify this implementation are welcome.

Thanks in advance.


-- 

3. Layout - Is there some way to do wraparound with horizontal linear layout

4. how can i save my overlays?

5. Motodev Studio for Android Dev?

6. Reminder: IRC office hours tomorrow

7. Loading entire Asset folder