android - Create a simple timer in a game -


i grateful if explain how create simple timer in game starts off @ 30 seconds , goes until 0. @ 0 stop game , invoke method allow next player take turn.

any advice appreciated. thanks

edit:

import android.os.countdowntimer; import android.widget.textview;  public class mycount extends countdowntimer {     static textview timedisplay;      public mycount(long millisinfuture, long countdowninterval) {         super(millisinfuture, countdowninterval);     }      public void onfinish() {         timedisplay.settext("done!");     }      public void ontick(long millisuntilfinished) {         timedisplay.settext("left: " + millisuntilfinished / 1000);     } } 

in seperate class have created method:

public void settimer() {      timedisplay = new textview(this);     this.setcontentview(timedisplay);     mycount counter = new mycount(30000, 1000);     counter.start(); } 

within onclick method have called method above:

public void onclick(view v) {     settimer(); } 

i'd appreciate advice on this.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -