Code example for TypedArray

Methods: getBoolean, recycle

0
 
        public void init(Context context, AttributeSet attrs, int defStyle) {
            TypedArray a = context.obtainStyledAttributes(attrs, new int[]{
                    android.R.attr.state_activated
            }, defStyle, 0);
            setActivated(a.getBoolean(0, false));
            a.recycle();
        } 
 
        public int[] onCreateDrawableState(int extraSpace) {
            extraSpace += 1;
            int[] state = mOverlayInterface.superOnCreateDrawableState(extraSpace);
            state = _View.supportMergeDrawableStates(state, new int[]{
                    mOverlayInterface.isActivated() ? android.R.attr.state_activated : -android.R.attr.state_activated
            }); 
            return state;
        } 
    } 
}