I\'d like a simple mm:ss
timer to be displayed on my actionbar, be able to pick the number of minutes to start counting down from and then call a method once it\'s
Menu xml
-
**public boolean onCreateOptionsMenu(Menu menu)"
long timer = 10000;
public Boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu, menu);
final MenuItem counter = menu.findItem(R.id.counter);
new CountDownTimer(timer, 1000) {
public void onTick(long millisUntilFinished) {
long millis = millisUntilFinished;
String hms = (TimeUnit.MILLISECONDS.toHours(millis))+":"+(TimeUnit.MILLISECONDS.toMinutes(millis) -TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)))+":"+ (TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
counter.setTitle(hms);
timer = millis;
}
public void onFinish() {
counter.setTitle("done!");
}
}.start();
return true;
}