Skip to content

Instantly share code, notes, and snippets.

@antew
Created February 17, 2013 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antew/4973312 to your computer and use it in GitHub Desktop.
Save antew/4973312 to your computer and use it in GitHub Desktop.
/**
* Returns true if the username and password pass validation.
*
* @return False if the username or password is blank
*/
private boolean hasErrors() {
boolean hasErrors = false;
Drawable errorIcon = getErrorDrawable();
String errorText = null;
if (username.getText().length() == 0) {
errorText = getString(R.string.enter_a_username);
username.setError(errorText, errorIcon);
hasErrors = true;
}
if (password.getText().length() == 0) {
errorText = getString(R.string.enter_a_password);
password.setError(errorText, errorIcon);
hasErrors = true;
}
return hasErrors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment