Code example for StateListDrawable

Methods: setState

0
    } 
 
    public void setState(int[] state) {
        if (mDrawable instanceof StateListDrawable) {
            StateListDrawable d = (StateListDrawable) mDrawable;
            d.setState(state);
        } 
    } 
 
    public boolean hasState(int[] state) {
        if (mDrawable instanceof StateListDrawable) {
            StateListDrawable d = (StateListDrawable) mDrawable;
            // TODO: this doesn't seem to work 
            try { 
                return (Integer) mGetStateDrawableIndex.invoke(d, state) != -1;
            } 
            catch (Exception e) {
                Log.w(TAG, "StateListDrawable#getStateDrawableIndex(int[]) call failed!", e);
            } 
        } 
        return false;