Java tutorial
//package com.java2s; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; public class Main { public static StateListDrawable getSelector(Drawable normalDraw, Drawable pressedDraw) { StateListDrawable stateListDrawable = new StateListDrawable(); stateListDrawable.addState(new int[] { android.R.attr.state_enabled }, pressedDraw); stateListDrawable.addState(new int[] {}, normalDraw); return stateListDrawable; } }