An apology for my bad English, I\'m using google translate.
I\'m creating an activity in which users must create a new profile. I put a limit to edit text of 15 char
As I can´t comment on other posts, I will complement the most voted answer with a tip for a more fashion visual resolution.
First, pass the Edittext (etNombre) data to a String variable.
Ex: String nombre = etNombre.getText().toString();
Then, use an if to verify:
if (!nombre.matches("[a-zA-Z.? ]*")) {
etNombre.setError("Your message here");
}
this solution will set an "!" icon on the Edittext and it's much better than a Toast because the message is pointing the user to the error.