Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; public class Main { /** * @param context * @param res * @return */ public static String color2hex(Context context, int res) { int color = context.getResources().getColor(res); String s = Integer.toHexString(color); if (s.length() == 8) { s = s.substring(2); } return s; } }