I added an OnFocusChangeListener to my EditText so that I can do some validation on the value when the user clicks outside, or tabs out of, the EditText view:
EditText myEditText = (EditText) itemView.findViewById(R.id.myedittext);
myEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
EditText editText = (EditText)view;
if (!hasFocus) {
validate(editText.getText().toString());
}
}
}
However, it appears the onFocusChange() method is being called like a textChanged() method. It's getting called every time I enter anything into the text field. I tried this on both a 2.2 simulator and my own hardware device and they act the same.
I would appreciate any insight on how the OnFocusChangeListener should work and why it's working the way it is for me.
Thank you in advance.