Skip to content

Instantly share code, notes, and snippets.

@antew
Created February 17, 2013 20:36
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/4973320 to your computer and use it in GitHub Desktop.
Save antew/4973320 to your computer and use it in GitHub Desktop.
getErrorDrawable
/**
* Returns an error icon for use with
* {@link EditText#setError(CharSequence)}
*
* @return A {@link Drawable} of the error icon
*/
public Drawable getErrorDrawable() {
Resources r = getActivity().getResources();
Drawable drawable
= r.getDrawable(R.drawable.custom_indicator_input_error);
/**
* We have to set the bounds here because they will default
* to zero for all values, meaning our icon will not display
*/
drawable.setBounds(0, // Left
0, // Top
drawable.getIntrinsicWidth(), // Right
drawable.getIntrinsicHeight()); // Bottom
return drawable;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment