public static void setState(final Drawable drawable, final int stateBitset) {
		final int[] states = new int[3];
		int index = 0;
		if ((stateBitset & ITEM_STATE_PRESSED_MASK) > 0)
			states[index++] = android.R.attr.state_pressed;
		if ((stateBitset & ITEM_STATE_SELECTED_MASK) > 0)
			states[index++] = android.R.attr.state_selected;
		if ((stateBitset & ITEM_STATE_FOCUSED_MASK) > 0)
			states[index++] = android.R.attr.state_focused;

		drawable.setState(states);
	}
public static void setState ( final Drawable drawable , final int stateBitset ) { final int [ ] states = new int [ 3 ] ; int index = 0 ; if ( ( stateBitset & ITEM_STATE_PRESSED_MASK ) > 0 ) states [ index ++ ] = android . R . attr . state_pressed ; if ( ( stateBitset & ITEM_STATE_SELECTED_MASK ) > 0 ) states [ index ++ ] = android . R . attr . state_selected ; if ( ( stateBitset & ITEM_STATE_FOCUSED_MASK ) > 0 ) states [ index ++ ] = android . R . attr . state_focused ; drawable . setState ( states ) ; }
/*
(copied from the Google API docs) Sets the state of a drawable to match a given state bitset.
This is done by converting the state bitset bits into a state set of R.attr.state_pressed,
R.attr.state_selected and R.attr.state_focused attributes, and then calling {@link
Drawable.setState(int[])}.