Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 1.13 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Countdown Timer problem
  2. public class MyCount extends CountDownTimer{
  3.  
  4. public MyCount(long millisInFuture, long countDownInterval) {
  5. super(millisInFuture, countDownInterval);
  6. }
  7.  
  8. @Override
  9. public void onFinish() {
  10. tv_test.setText("");
  11. }
  12.  
  13. @Override
  14. public void onTick(long millisUntilFinished) {
  15. tv_test.setText("d"+ (millisUntilFinished/(3600000*24))+ " h: "+  (millisUntilFinished/3600000)%24  +" m: " +  (millisUntilFinished/60000) % 60 + " sec: "+   (millisUntilFinished/1000) % 60);
  16.  
  17. }
  18.  
  19. }
  20.        
  21. MyCount counter = new MyCount(time, 1000);
  22.         counter.start();
  23.        
  24. booelan counterIsLaunched = false;
  25. boolean timeChanged = false;
  26.        
  27. @Override
  28. public void onFinish() { tv_test.setText("");
  29. counterIsLaunched = false;
  30. if(timeChanged) start();
  31. }
  32. @Override
  33. public void onTick(long millisUntilFinished) {
  34. tv_test.setText("d"+ (millisUntilFinished/(3600000*24))+ " h: "+  (millisUntilFinished/3600000)%24  +" m: " +  (millisUntilFinished/60000) % 60 + " sec: "+   (millisUntilFinished/1000) % 60);
  35. counterIsLaunched = true;
  36. if(timeChanged) start();
  37. }
  38.        
  39. if(counter.getCounterIsLaunched() == false ) {
  40. counter.start();
  41. }
  42.        
  43. counter.getTimeChanged() = true;