Java tutorial
//package com.java2s; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; public class Main { public static StateListDrawable getCheckedSelectorDrawable(Drawable normal, Drawable pressed) { StateListDrawable bg = new StateListDrawable(); bg.addState(new int[] { android.R.attr.state_checked, android.R.attr.state_enabled }, pressed); bg.addState(new int[] { android.R.attr.state_enabled }, normal); bg.addState(new int[] {}, normal); return bg; } }