TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.MyCustomView); int defaultValue = 0; int myCustomInteger = attributes.getInteger(R.styleable.MyCustomView_customIntegerAttribute, defaultValue);
TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.colorPrimary, outValue, true); int colorPrimary = outValue.data;In this example, the getInteger method is not used directly. Instead, the resolveAttribute method is used to retrieve an integer value from a theme attribute (in this case, android.R.attr.colorPrimary). The value is then stored in the "data" field of a TypedValue object. The android.content.res.TypedArray package library is part of the Android platform SDK.