Code example for StateListDrawable

Methods: setState

0
    } 
 
    public void setState(int [] state) {
        if (mDrawable instanceof StateListDrawable) {
            StateListDrawable d = (StateListDrawable) mDrawable;
            d.setState(state);
        } 
    } 
 
    /** 
     * Returns true if the drawable is a StateListDrawable and is in the focused state. 
     * 
     * @return 
     */ 
    public boolean isActive() { 
        if (mDrawable instanceof StateListDrawable) {
            StateListDrawable d = (StateListDrawable) mDrawable;
            int[] states = d.getState();
            for (int i = 0; i < states.length; i++) {
                if (states[i] == android.R.attr.state_focused) {
                    return true;