Android handle continuous tapping on buttons -


may question needs logic only.

we have android app invokes different web services , return data. in app there 2 buttons. have 10 apis (web services). button 1 invoke apis api1, api 2 api 3 , api n. button 2 invoke api10, api9, api 8… api 1. invoking apis in button click using following code

handler.postdelayed(new runnable() {     public void run() {         switchtoapi(true);     } }, 100); 

as of implementation in each click invoking apis. if tapped in button1 invoke api1 , can perform other operations after api1 completed. want, user can continuously tap on buttons. continues tap need not invoke api. api number can changed. if user tapas , wait 2 seconds without taping, corresponding apis should called. can suggest , mechanism?

please try use code below:

public static void buttonlockthread(final int id, final activity activity) {     thread thread = new thread(new runnable() {          @override         public void run() {             // todo auto-generated method stub             try {                 thread.sleep(500);             } catch (interruptedexception e) {                 // todo auto-generated catch block                 e.printstacktrace();              }             activity.findviewbyid(id).setclickable(true);         }      });     thread.start();  }  public void onclick(view v) {     // todo auto-generated method stub     switch (v.getid()) {     case r.id.armdsarmbutton:         findviewbyid(r.id.armdsarmbutton).setclickable(false);         webservicecontroller.getarmdisarmrelayinfo(this, defaultpanelid);         calculations.buttonlockthread(r.id.armdsarmbutton, this);         break;     default:         break;     } } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -