Java tutorial
//package com.java2s; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.DrawableRes; public class Main { public static Drawable getDrawable(Resources res, Resources.Theme theme, @DrawableRes int id) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return res.getDrawable(id); } return res.getDrawable(id, theme); } }