Code example for TypedArray

Methods: getColor, recycle

0
 
        /* get attribute array */ 
        TypedArray ta = context.obtainStyledAttributes(parser, sStyleable.resolveIntArray("Stage"));
 
        /* set StageBgColor */ 
        int stageBgColor = ta.getColor(sStyleable.resolveInt("Stage_backgroundColor"), -1);
        log(TAG, "Stage stageBgColor : " + stageBgColor);
        if (stageBgColor != -1) {
            stage.setBackgroundColor(new Color(stageBgColor));
        } 
 
        ta.recycle();
        return stage;
    } 
 
    /** 
     * parse attribute of text in the xml parser 
     * 
     * @param context : the application environment 
     * @param parser: the xml resource parser created from the xml file 
     * @return the text object