FanHamMer

Backtime

May 24th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. tv = new TextView(this);
  2.     this.setContentView(tv);
  3.  
  4. //10000 is the starting number (in milliseconds)
  5. //1000 is the number to count down each time (in milliseconds)
  6. MyCount counter = new MyCount(10000,1000);
  7.  
  8. counter.start();
  9.  
  10. }
  11.  
  12. //countdowntimer is an abstract class, so extend it and fill in methods
  13. public class MyCount extends CountDownTimer
  14. {
  15.  
  16. public MyCount(long millisInFuture, long countDownInterval)
  17. {
  18. super(millisInFuture, countDownInterval);
  19. }
  20.  
  21. public void onFinish()
  22. {
  23. tv.setText("Time Up!");
  24. }
  25.  
  26. public void onTick(long millisUntilFinished)
  27. {
  28. tv.setText("Time Left : " + millisUntilFinished/1000);
  29.  
  30. }
Add Comment
Please, Sign In to add comment