0
votes
val CountDownTimer=object: CountDownTimer(10000,1000){
            override fun onTick(millisUntilFinished: Long) {
                txtTimer.setText(millisUntilFinished/1000)
            }

            override fun onFinish() {
                Toast.makeText(this@Play_Area,"Time up",Toast.LENGTH_SHORT).show()
            }
        }
        CountDownTimer.start()

I am passing countdown to the xml in onTick funtion it is showing following error in setText :

None of the following functions can be called with the arguments supplied: public final fun setText(p0: CharSequence!): Unit defined in android.widget.TextView public final fun setText(p0: Int): Unit defined in android.widget.TextView

Please help...

1
txtTimer.setText((millisUntilFinished/1000).toString())IntelliJ Amiya

1 Answers

0
votes

It's because you are setting the long value in a string input type function. Just concatenate your long value with string to show it on your TextView like

textView.setText("" + millisUntilFinished/1000)

Hope the answer to the question.