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
You may resolve this problem a much shorter:
@Override
protected void onResume() {
super.onResume();
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();
}
};
editLogin.addTextChangedListener(tw);
editPassword.addTextChangedListener(tw);
}
private void updateSignInButtonState() {
buttonSignIn.setEnabled(editLogin.getText().length() > 0 &&
editPassword.getText().length() > 0);
}