Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Color; import android.text.TextUtils; public class Main { public static int hex2color(String color) { if (TextUtils.isEmpty(color)) { color = "#ffffff"; } int result; if (color.charAt(0) != '#') { color = "#" + color; } result = Color.parseColor(color); return result; } }