// Obtaining the resource ID of a theme attribute TypedArray ta = getContext().getTheme().obtainStyledAttributes( new int[] { android.R.attr.textColorPrimary } ); int primaryTextColorResourceId = ta.getResourceId(0, 0); ta.recycle();
// Obtaining the resource ID of an Android system attribute TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute( android.R.attr.listPreferredItemHeight, outValue, true ); int itemHeightResourceId = outValue.resourceId;This example obtains the resource ID of the `listPreferredItemHeight` attribute, which is a system attribute defined in the Android framework. The method `resolveAttribute` is called on the current theme to resolve the attribute to its actual value, which is stored in the `outValue` object. The `resourceId` field of `outValue` is then used to obtain the resource ID of the attribute. Both examples use the `android.content.res` package, which is part of the Android framework and provides classes for accessing resources in a structured way.