Code example for AttributeSet

Methods: getAttributeIntValue, getAttributeValue

0
		//mSeekBar.setMax(mMaxValue - mMinValue); 
		//mSeekBar.setOnSeekBarChangeListener(this);	 
		} 
 
	private void setValuesFromXml(AttributeSet attrs) {
		mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
		mMinValue = attrs.getAttributeIntValue(ROBOBUNNYNS, "min", 0);
 
		mUnitsLeft = getAttributeStringValue(attrs, ROBOBUNNYNS, "unitsLeft",
				""); 
		String units = getAttributeStringValue(attrs, ROBOBUNNYNS, "units", "");
		mUnitsRight = getAttributeStringValue(attrs, ROBOBUNNYNS, "unitsRight",
				units);
		 
		mCurrentValue = attrs.getAttributeIntValue(ANDROIDNS, "summary", 100);
 
		try { 
			String newInterval = attrs.getAttributeValue(ROBOBUNNYNS,
					"interval"); 
			if (newInterval != null)
				mInterval = Integer.parseInt(newInterval);
		} catch (Exception e) {
			Log.e(TAG, "Invalid interval value", e);
		} 
 
	} 
 
	private String getAttributeStringValue(AttributeSet attrs,
			String namespace, String name, String defaultValue) {
		String value = attrs.getAttributeValue(namespace, name);
		if (value == null)
			value = defaultValue;
 
		return value;
	}