Java tutorial
//package com.java2s; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.support.annotation.StyleableRes; public class Main { public static Drawable getDrawable(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) { Drawable val = a.getDrawable(index); if (val == null) { return a.getDrawable(fallbackIndex); } return val; } }