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