Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Color; public class Main { static public int getColor(Context context, String name) { int identifier = context.getResources().getIdentifier(name, "color", context.getPackageName()); if (identifier > 0) { return context.getResources().getColor(identifier); } return Color.TRANSPARENT; } static public int getIdentifier(Context context, String name) { return context.getResources().getIdentifier(name, "id", context.getPackageName()); } }