how to keep button disable any editText Empty?

how to keep button disable any editText Empty ?

i’ve try with implementation 'androidx.core:core-ktx:1.1.0':

txtEmailOrNoPhone.doOnTextChanged { text, start, count, after ->
            if (text.toString().isEmpty()) {
                buttonLogin.isEnabled = false
            } else {
                txtPassword.doOnTextChanged { text, start, count, after ->
                    buttonLogin.isEnabled = text.toString().isNotEmpty()
                }
            }
        }

but, not work.

because, if i run app (button enable). if i type and delete all (button disable). so, i must type first and delete to (button disable)

i want : if start app

Answer

Since your code inside the doOnTextChanged is not triggered until you type something, your initial state of disabling the button will not work.

For that, just set the button disabled initially in the xml

android:enabled="false"