Java tutorial
//package com.java2s; import android.graphics.Color; public class Main { public static int parseColorFromString(String color) { int colorInt; if (color != null && !color.isEmpty() && !color.substring(0, 1).equals("#")) { colorInt = Color.parseColor("#" + color); } else { colorInt = Color.parseColor(color); } return colorInt; } }