When the activity is opened, the button is inactive. How to activate the button as soon as they started typing text in EditText

    1 answer 1

    editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { button.setEnabled(true); } @Override public void afterTextChanged(Editable s) { } }); 
    • Thank! Exactly what is needed. - user215435
    • And how to make sure that if the text is cleared, the button becomes inaccessible again? - user215435
    • On the afterTextChange method, take the editable length and if it is 0, do the button.setEnabled (false) - pavel163
    • thanks helped - user215435