I want to display the timer in TextView in the format of like [ 19:59].so when i click the start button ,the timer will display like this for example,i want to set upto 20 mintues,it will display like [19:58][19:87].can anyone give some ideas or example code?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
This can be done using cronometer, the most main reason is supporting API 1+, which is quite impressive rather than TextClock, which supports API 17+.
You can do lots of other things with cronometer. for example you can set start time in it
You can also learn about it more here.
You can use the
CountDownTimer
.http://developer.android.com/reference/android/os/CountDownTimer.html
To cancel just call cancel on the timer.
public final void cancel()
Cancel the countdown.
Here I have use Timer class to display timer
In layout, there are one TextView and one Button to start timer. I have use Timer class method
scheduleAtFixedRate
. Time will be displayed in hh:mm:ss form.do it this way activity_timer.xml
And in Activity
You can also use stop
Re Start