Code example for TypedArray

Methods: getColor, recycle

0
 
	public int getColor(String attrName, int defaultValue) {
		int[] attr = ThemeUtils.getAttributeIds(mContext,
				new String[] { attrName }, mPackageName);
		TypedArray a = mContext.obtainStyledAttributes(mThemeId, attr);
		int c = a.getColor(0, defaultValue);
		a.recycle();
		return c;
	} 
 
	public int getDimensionPixelOffset(String attrName, int defaultValue) {
		int[] attr = ThemeUtils.getAttributeIds(mContext,
				new String[] { attrName }, mPackageName);
		TypedArray a = mContext.obtainStyledAttributes(mThemeId, attr);
		int i = a.getDimensionPixelOffset(0, defaultValue);
		a.recycle();
		return i;
	} 
 
	public int getInteger(String attrName, int defaultValue) {
		int[] attr = ThemeUtils.getAttributeIds(mContext,