Code example for Resources.Theme

Methods: resolveAttribute

0
     */ 
    public static float getAttributeDimension(final Context context, final Theme theme, final int resId) {
        final TypedValue typedValue = new TypedValue(); // create a new typed value to received the resolved attribute
                                                        // value 
        final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        if (!theme.resolveAttribute(resId, typedValue, true)) // if we can't resolve the value
        { 
            throw new NotFoundException("Resource ID #0x" + Integer.toHexString(resId));
        } 
        if (typedValue.type != TypedValue.TYPE_DIMENSION) // if the value isn't of the correct type
        { 
            throw new NotFoundException("Resource ID #0x" + Integer.toHexString(resId) + " type #0x"
                    + Integer.toHexString(typedValue.type) + " is not valid");
        } 
        return typedValue.getDimension(displayMetrics); // return the value of the attribute in terms of the display
    } 
 
    /** 
     * Returns the list preferred item height theme attribute as a dimension of the display. 
     *  
     * @param context