Too many arguments for public open fun isEnabled()

1.1k views Asked by At

I want to disable the editText once timer is finished. Have a look on the following code:

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()
        etResponse.isEnabled(false)
    }
}

Here etResponse is EditText and when i make #isEnables(false) it is showing following error:

Too many arguments for public open fun isEnabled(): Boolean defined in android.widget.EditText

Please Help How to resolve it

1

There are 1 answers

0
Hamza Sharaf On

You are using the wrong function.

editText.isEnabled() is used to return the enabled state only and it doesn't take an argument so you can call it like that

val state: Boolean = editText.isEnabled()

instead, you should use editText.isEnabled = true because the property is mutable

editText.isEnabled = false