I have a validation for an editText where a user inputs an id. The id has a minimum length of 6 and has error detection. I want to inform the user when a correct id is entered right away. I've searched online and most of what i've found is the case of telling the user of invalid input through methods like editText.setError()
. So my question is, is there a setError
equivalent for when the user has done the correct thing.
Asked
Active
Viewed 391 times
0

fuadj
- 434
- 4
- 10
-
what are the conditions to enter a correct id ? at least 6 caracters and I guess be unique ? And how would you like to display the message ? – Alexandre Martin Jul 05 '16 at 21:45
-
I want to display it as `setError` displays errors, only with a green indicator to tell success – fuadj Jul 05 '16 at 21:47
-
i can do success indication by displaying a `Toast`, but that isn't as preferable as the status `setError` displays when there is an error. I want to display success as `setError` displays error. – fuadj Jul 05 '16 at 21:54
2 Answers
1
You can use the TextChangeListener to perform events when the user changes the text.
textEdit.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
// validate text and inform user
}
});

bradkratky
- 1,577
- 1
- 14
- 28
-
1i do watch for the user's text changes, my question is about displaying a *_success_* indicator when the user gets it right, keep in mind the id can be long so i want to give a direct feedback when the user inputs the right id – fuadj Jul 05 '16 at 21:51
-
Ah. I don't think there is an official one, but maybe you could customize the icon to produce the effect you're looking for? This question shows how to subclass and change the icon, though they are also disabling the text. http://stackoverflow.com/questions/8985295/edittext-seterror-with-icon-but-without-popup-message – bradkratky Jul 05 '16 at 21:52
-
0
We can set the style of the setError popup with fromHtml method.
You can also use this : https://github.com/sherifelkhatib/WidgyWidgets

Alexandre Martin
- 1,472
- 5
- 14
- 27