You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lets say we have 3 Material Edittexts, For all I have kept empty validation. Now, if I enter some text in the first edit text and goto the next, there is no problem. But if I leave the first one empty, and go to the next one, the Edittext cursor shows on both of them and i could not edit or focus the first one, struck in the second one. This was the issue, then, on analyzing it. found that a method requestFocus() in the class MaterialEditText.java inside a function validate() was causing the problem, commented it out, and now it works fine:
public boolean validate() {
if (validators == null || validators.isEmpty()) {
return true;
}
CharSequence text = getText();
boolean isEmpty = text.length() == 0;
boolean isValid = true;
for (METValidator validator : validators) {
//noinspection ConstantConditions
isValid = isValid && validator.isValid(text, isEmpty);
if (!isValid) {
setError(validator.getErrorMessage());
//-------------------------------this line was causing the problem---------------------------------------
//requestFocus();
break;
}
}
if (isValid) {
setError(null);
}
postInvalidate();
return isValid;
}
The text was updated successfully, but these errors were encountered:
ReejeshPK
changed the title
Edittext Focuses on Multiple Edittexts during validation error
MaterialEditText Focuses on Multiple Edittexts during validation error
Nov 18, 2018
Lets say we have 3 Material Edittexts, For all I have kept empty validation. Now, if I enter some text in the first edit text and goto the next, there is no problem. But if I leave the first one empty, and go to the next one, the Edittext cursor shows on both of them and i could not edit or focus the first one, struck in the second one. This was the issue, then, on analyzing it. found that a method requestFocus() in the class MaterialEditText.java inside a function validate() was causing the problem, commented it out, and now it works fine:
The text was updated successfully, but these errors were encountered: