get Drawable By Color Id from resource - Android App

Android examples for App:Resource

Description

get Drawable By Color Id from resource

Demo Code

/**/*from  ww  w  . j a va 2s .  co m*/
 * Created by irrienberith on 14-11-19, 11:43.
 * All rights reserved.
 */
//package com.java2s;
import android.content.Context;
import android.graphics.drawable.Drawable;

public class Main {
    public static Drawable getDrawableByColorId(Context paramContext,
            String paramString) {
        return paramContext.getResources().getDrawable(
                getColorId(paramContext, paramString));
    }

    public static int getColorId(Context paramContext, String paramString) {
        return paramContext.getResources().getIdentifier(paramString,
                "color", paramContext.getPackageName());
    }
}

Related Tutorials