CHRONOMETER IN ANDROID
Chronometer in Android is useful to implement a simple Timer. It is a subclass of TextView however holds a countdown or count up timer.
Steps to implement chronometer in Android are given below
First step is to add some strings in strings xml
Write strings given below
Next step to design layout
Add 4 buttons
Set constraints and I’d for buttons
First button text start
Second stop
Third button apply format
Fourth button for clear format
Add chronometer in activity main xml-
In main activity
Write code given below
view.onclicklistener
Override fun on create(saved instance saved:bundle?){
super.on create(saved instance state)
set content view(R.layout.activity_main
Btn_clear_format.setonclicklistener
btn_start.setonclicklistener
btn_stop.setonclicklistener
btn_apply_format.setonclicklistener
timer.setonclicklistener{
Toast.maketext(context this,main activity,text “tick happened”,Toast.LENGTH_LONG).show()
}
override fun on click(p0:view?}{
when(p0?.Id)
{
R.id.btn_stop->timer.stop()
R.id.btn_start->timer.start()
R.id.btn_format->timer.format()=”timer is running:
else-> timer.format=null
Finish
Hello very cool website!! Guy .. Excellent .. Superb .. Annaliese Prince Ilse
Really enjoyed this blog post. Thanks Again. Keep writing. Cammi Itch Bascomb
I conceive you have mentioned some very interesting points , thankyou for the post. Valeria Gray Brucie
As I website owner I believe the content material here is very superb, thanks for your efforts. Cherye Anders Arela
Way cool! Some very valid points! I appreciate you writing this write-up plus the rest of the website is really good. Nan Ancell Noble
Muchos Gracias for your post. Really looking forward to read more. Really Great. Leandra Sergio Igenia
You have brought up a very superb points, appreciate it for the post. Sydelle Arther Juna
It as very straightforward to find out any matter on net as compared to books, as I found this article at this web page. Juliane Keven Seldan
Check out the latest news on her website:Hello and welcome. Tera Dickie Mansur
Muchos Gracias for your blog post. Thanks Again. Awesome. Gerrilee Barclay Merrill
Thanks-a-mundo for the blog. Really lookI amcik embesil babag forward to read more. Awesome. Faythe Jerrold Fabrianne