Code example for TypedArray

Methods: getDrawable, getInt, recycle

0
        if (R.styleable.Slider != null) {
        	TypedArray sa = context.obtainStyledAttributes(attrs,
	                R.styleable.Slider);
	         
	        if (R.styleable.Slider_min != UNUSED)
	        	min = sa.getInt(R.styleable.Slider_min, min);
	        if (R.styleable.Slider_max != UNUSED)
	        	max = sa.getInt(R.styleable.Slider_max, max);
	        if (R.styleable.Slider_pos != UNUSED)
	        	pos = sa.getInt(R.styleable.Slider_pos, pos);
	        if (R.styleable.Slider_background != UNUSED) {
	        	/*res = sa.getInt(R.styleable.Slider_background, UNUSED); 
	        	if (res != UNUSED) { 
	        		setBackground(getResources().getDrawable(res)); 
	        	}*/ 
	        	setBackground(sa.getDrawable(R.styleable.Slider_background));
	        } 
	        if (R.styleable.Slider_knob != UNUSED) {
	        	setKnob(sa.getDrawable(R.styleable.Slider_knob));	
	        } 
	         
	        sa.recycle();
        } 
         
        background = null;
        knob = null;
    }