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