Android Button click being processed twice

I have a submit button on a form that submits the form.  The problem is, if the user double clicks or taps on the button it is getting processed multiple times.  I have tried to deactivate the button the first time it is selected but then the button does not process at all on Android 2.2 but seems to work on more current versions.  What is the best way to ensure that the button is only selected once.
nvbobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yianniscy84Commented:
An easy way that just popped in my head is to increase a counter every time the button is pressed and process the request only if counter=1 :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SanthanaTechnical LeadCommented:
hi  nvbob,

Implement both onClick and onTouch listener for the button.
And set a flag in class level


private static boolean mIsButtonClicked = false;

public boolean onTouch(View aView, MotionEvent aEvent){
              if(aEvent.getAction() == MotionEvent.ACTION_DOWN){
                          mIsButtonClicked = true;
              }
              if(aEvent.getAction() == MotionEvent.ACTION_UP){
                          mIsButtonClicked = false;
              }
            return false;
}
public void onClick(View aView){
           if(mIsButtonClicked){
                      return;
             }
              //Do ur things here
}


I thing in this way u can ensure that only one time u r button is selected...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Android

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.