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