Update strings.xml file
Here, we update the name of the application using the string tag. We also other strings which can be used in MainActivity.kt file.
XML
< resources > < string name = "app_name" >ChronometerInKotlin</ string > < string name = "stop" >Stop Timer</ string > < string name = "start" >Start Timer</ string > < string name = "working" >Started</ string > < string name = "stopped" >Stopped</ string > </ resources > |
Chronometer in Kotlin
Android ChronoMeter is user interface control which shows timer in the view. We can easily start up or down counter with base time using the chronometer widget. By default, start() method can assume base time and starts the counter.
Generally, we can create use ChronoMeter widget in XML layout but we can do it programmatically also.
First we create a new project by following the below steps:
- Click on File, then New => New Project.
- After that include the Kotlin support and click on next.
- Select the minimum SDK as per convenience and click next button.
- Then select the Empty activity => next => finish.