Code example for ColorDrawable

Methods: getColor

0
     * @param alpha   indicate if want to get color with alpha   ff ffffff 
     * @return  hex code of drawable object API > 10 REQUIRED 
     */ 
    public static String giveMeHexCode(ColorDrawable colorDrawable,boolean alpha)
    { 
        return alpha?"#"+Integer.toHexString(colorDrawable.getColor()):"#"+Integer.toHexString(colorDrawable.getColor()).substring(2);
    } 
 
    /** 
     * 
     * @param color 
     * @param alpha   indicate if want to get color with alpha   ff ffffff 
     * @return  hex code of drawable object 
     */ 
    public static String giveMeHexCode(Integer color,boolean alpha)
    { 
        return alpha?"#"+Integer.toHexString(color):"#"+Integer.toHexString(color).substring(2);
    } 
 
 
    /**