Code example for XmlPullParser

Methods: createFromXmlInner, getName

0
 
    public static Drawable createFromXml(Resources r, XmlPullParser parser)
            throws XmlPullParserException, IOException { 
        AttributeSet attrs = Xml.asAttributeSet(parser);
        int type;
        while ((type = parser.next()) != XmlPullParser.START_TAG &&
                type != XmlPullParser.END_DOCUMENT) {
        } 
        if (type != XmlPullParser.START_TAG) {
            throw new XmlPullParserException("No start tag found");
        } 
        Drawable drawable = createFromXmlInner(r, parser, attrs);
        if (drawable == null) {
            throw new RuntimeException("Unknown initial tag: " + parser.getName());
        } 
        return drawable;
    } 
 
    public static Drawable createFromXmlInner(Resources r, XmlPullParser parser, AttributeSet attrs)
            throws XmlPullParserException, IOException { 
        Drawable drawable = null;
        final String name = parser.getName();
        try {