disable button if edittext is not change code example
Example: disable button when edittext is empty kotlin
editText1.addTextChangedListener(object: TextWatcher {
override fun onTextChanged(s:CharSequence, start:Int, before:Int, count:Int) {
if (s.toString().trim({ it <= ' ' }).isEmpty())
{
button.setEnabled(false)
}
else
{
button.setEnabled(true)
}
}
override fun beforeTextChanged(s:CharSequence, start:Int, count:Int,
after:Int) {
// TODO Auto-generated method stub
}
override fun afterTextChanged(s: Editable) {
// TODO Auto-generated method stub
}
})