I have two text fields and a Button. I want to disable the Button unless both EditText-Fields are not empty. I tried many solutions here at stackoverflow, but they don\'t wo
My way was:
button setEnabled(false)
I used TextWatcher to listen for text change and update status of
button in afterTextChanged function
Here is my code:
TextWatcher tw = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
updateSignInButtonState();
}
};
public void updateSignInButtonState() {
btnSubmit.setEnabled(edUsername.getText().length() > 0 &&
edPassword.getText().length() > 0);
}