Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; public class Main { private static Context context; public static int getResColorID(String resName) { Resources res = context.getResources(); return res.getIdentifier(resName, "color", context.getPackageName()); } }