I'm trying to blink a text (based on a previous button click) but my App crashes after 1000ms/2000ms.
I have tried to create a thread but I'm not sure if it is the easiest way. Can someone help me?
This is my current code:
fun toggleBlinkCounterUI() {
/*var handler: Handler = Handler();
Thread(Runnable() {
override fun run() {
var timeToBlink: Long = 1000;
Thread.sleep(timeToBlink)
handler.post(Runnable() {
fun run() {
if (binding.exerciseTimer.visibility == View.VISIBLE){
binding.exerciseTimer.visibility = View.INVISIBLE
} else {
binding.exerciseTimer.visibility = View.VISIBLE
}
toggleBlinkCounterUI();
}
});
}
}).start();*/
/*val thread = Thread {
var timeToBlink: Long = 1000;
while (1 == 1) {
Thread.sleep(timeToBlink)
if (binding.exerciseTimer.visibility == View.VISIBLE){
binding.exerciseTimer.visibility = View.INVISIBLE
} else {
binding.exerciseTimer.visibility = View.VISIBLE
}
}
}
thread.start()*/
Thanks in advance
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…