Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; public class Main { public static Drawable getDrawableFromRes(int res, Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return context.getResources().getDrawable(res, context.getTheme()); else return context.getResources().getDrawable(res); } }