Code example for TypedValue

0
public final class ResourceHelper { 
 
    private final static Pattern sFloatPattern = Pattern.compile("(-?[0-9]+(?:\\.[0-9]+)?)(.*)");
    private final static float[] sFloatOut = new float[1];
 
    private final static TypedValue mValue = new TypedValue();
 
    /** 
     * Returns the color value represented by the given string value 
     * @param value the color value 
     * @return the color as an int 
     * @throw NumberFormatException if the conversion failed. 
     */ 
    public static int getColor(String value) {
        if (value != null) {
            if (value.startsWith("#") == false) {
                throw new NumberFormatException(
                        String.format("Color value '%s' must start with #", value));
            } 
 
            value = value.substring(1);