Created
May 13, 2020 04:34
-
-
Save ricardoalcocer/17ec528d5eb4095243fd0b8ae5add461 to your computer and use it in GitHub Desktop.
Kotlin Android Countdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun stopCountDown(){ | |
val t = Toast.makeText(this,"Stopping countdown",Toast.LENGTH_SHORT).show() | |
timer1.cancel() | |
timer1IsRunning=false | |
} | |
private fun startCountDown(){ | |
timer1 = object : CountDownTimer(duration, interval) { | |
override fun onFinish() { | |
txtTimer1.text = "0" | |
timer1IsRunning=false | |
} | |
override fun onTick(millisUntilFinished: Long) { | |
txtTimer1.text = (millisUntilFinished / 1000).toString() | |
} | |
} | |
timer1.start() | |
timer1IsRunning=true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment