Created
February 17, 2013 20:36
-
-
Save antew/4973320 to your computer and use it in GitHub Desktop.
getErrorDrawable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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