get resource Color ID - Android App

Android examples for App:Resource

Description

get resource Color ID

Demo Code


//package com.java2s;
import android.content.Context;

public class Main {
    public static int getColorID(Context context, String key) {
        return context.getResources().getIdentifier(key, "color",
                context.getPackageName());
    }//from w w  w  . j  a  va 2s .  c  o  m
}

Related Tutorials