Code example for Resources.Theme

Methods: resolveAttribute

0
    /** 
     * Resolves the given attribute id of the theme to a resource id 
     */ 
    public static int getAttribute(Theme theme, int attrId) {
        final TypedValue outValue = new TypedValue();
        theme.resolveAttribute(attrId, outValue, true);
        return outValue.resourceId;
    } 
 
    /** 
     * Returns the resource id of the background used for buttons to show 
     * pressed and focused state 
     */ 
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public static int getSelectableItemBackground(Theme theme) {
        if (hasHoneycomb()) { 
            return getAttribute(theme, android.R.attr.selectableItemBackground);
        } 
        return 0; 
    }