Steph is trying to implement a function to be called whenever a button is clicked. She uses another thread to do a few calculations, then updates the UI for her app. However, the code is not working. Help her and identify the problem.
button.setOnClickListener {
thread {
for (i in 0..5) {
Thread.sleep(100) // pretend doing some calculations
counterTextView.text = i.toString() // update the UI
}
}
}