Java tutorial
//package com.java2s; import android.content.res.ColorStateList; import android.content.res.Resources; import android.os.Build; import android.support.annotation.ColorRes; public class Main { public static ColorStateList getColorStateList(Resources res, Resources.Theme theme, @ColorRes int id) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return res.getColorStateList(id); } return res.getColorStateList(id, theme); } }