It should not be too complicated. You have already created your functionality for writing your time in letters, now you need to pay attention. Starting the timer is simple, just do it in the start button's event handler (or whatever you decide to use) (modified example from the Android developer link
// New timer for 10 minutes, starts after initialization new MyCount(600000, 1000) { // Updates the text on your "scoreboard" every second public void onTick(long millisUntilFinished) { Timer.setText("Time remaining: " + formatTime(millisUntilFinished)); } public void onFinish() { mTextField.setText("done!"); } }.start();
And thatβs all you need! You can skip the UpdateTime function and your updateTimeTask . Just replace all of this with your onCreate method
counter = new MyCount(length, 1000); updateTime(); handler.removeCallbacks(updateTimeTask); handler.postDelayed(updateTimeTask, 1000);
With my code. Or change it as you please!
source share