Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.os.Build; public class Main { /** * @see android.content.res.Resources#getColorStateList(int id). */ @SuppressWarnings("deprecation") public static ColorStateList getColorStateList(Resources res, int id) throws NotFoundException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return res.getColorStateList(id, null); } else { return res.getColorStateList(id); } } }