Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.


Show the video description

In this video we will build a stopwatch that we can start, pause, resume and reset with help of the Chronometer widget. Chronometer is a subclass of TextView and automatically counts upwards when we call start on it. With setBase we define a time the Chronometer should count in relation to. If we want to start at 0 seconds, we have to pass Systemclock.elapsedRealtime. We can also easily change the format of the clock with help of the setFormat method, we can make it count downwards with setCountdown and we can implement an OnChronometerTickListener and override the onChronometerTick method to do something every second when the Chronometer updates.