Answers for "disable button when edittext is empty kotlin"

0

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
        }
    })
Posted by: Guest on March-07-2020

Code answers related to "disable button when edittext is empty kotlin"

Browse Popular Code Answers by Language