In one of my actions I have three buttons EditTextand OK. The value is OnFocusChangeListenerset to all three EditTexts. The listener should start every time the focus is lost.
Switching between EditTextworks fine. But if the user presses the OK button, pressing the button does not change focus (loss of focus), but the button EditTextfocuses on the user.
What is wrong with my code?
private class MyOnFocusChangeListener implements OnFocusChangeListener {
private EditText editText;
public MyOnFocusChangeListener(final EditText editText) {
super();
this.editText = editText;
}
@Override
public void onFocusChange(final View view, final boolean isFocused) {
if (!isFocused) {
if (editText == editText1) {
} else if (editText == editText2) {
} else if (editText == editText3) {
}
}
}
}
@Override
public void onCreate(final Bundle bundle) {
editText1.setOnFocusChangeListener(new MyOnFocusChangeListener(editText1));
editText2.setOnFocusChangeListener(new MyOnFocusChangeListener(editText2));
editText3.setOnFocusChangeListener(new MyOnFocusChangeListener(editText3));
}
source
share