Android XmlResourceParser - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android XmlResourceParser class.

This code example shows how to use the following methods:getAttributeValue
 
        private FixedClockPalette() { } 
 
        public static ClockPalette parseXmlPaletteTag(XmlResourceParser xrp) {
            final FixedClockPalette pal = new FixedClockPalette();
            pal.mId = xrp.getAttributeValue(null, "id");
            String val;
            if ((val = xrp.getAttributeValue(null, "background")) != null)
                pal.mBackgroundColor = Color.parseColor(val);
            if ((val = xrp.getAttributeValue(null, "second")) != null)
                pal.mSecondColor = Color.parseColor(val);
            if ((val = xrp.getAttributeValue(null, "minute")) != null)
                pal.mMinuteColor = Color.parseColor(val);
            if ((val = xrp.getAttributeValue(null, "hour")) != null)
                pal.mHourColor = Color.parseColor(val);
            if ((val = xrp.getAttributeValue(null, "day")) != null)
                pal.mDayColor = Color.parseColor(val);
            if ((val = xrp.getAttributeValue(null, "month")) != null)
                pal.mMonthColor = Color.parseColor(val);
            return (pal.mId == null) ? null : pal;

6
CodeRank
This code example shows how to use the following methods:getAttributeBooleanValue, getAttributeValue
	 * @param am the mapping details 
	 */ 
	private void parserDataPublications(XmlResourceParser parser,
			ActivityMapping am) {
 
		String populateMethod = parser
				.getAttributeValue(null, "populateMethod");
		String id = parser.getAttributeValue(null, "id");
		String query = parser.getAttributeValue(null, "query");
		String context = parser.getAttributeValue(null, "context");
		boolean autoPopulate = parser.getAttributeBooleanValue(null,
				"autoPopulate", true); 
		boolean useThumbnails = parser.getAttributeBooleanValue(null,
				"useThumbNailImages", false); 
 
		DataPublicationRequest publication = new DataPublicationRequest();
		publication.setPopulateMethod(populateMethod);
		publication.setAutoPopulate(autoPopulate);
		publication.setContext(context);
		publication.setId(id);
6
CodeRank
This code example shows how to use the following methods:getAttributeResourceValue, getAttributeValue
     * @param name  The attribute name 
     * 
     * @return  The value of the attribute 
     */ 
    private String getXmlAttribute(XmlResourceParser xrp, String name) {
        int resId = xrp.getAttributeResourceValue(null, name, 0);
        if (resId == 0) {
            return xrp.getAttributeValue(null, name);
        } else { 
            return mWnn.getString(resId);
        } 
    } 
 
    /** 
     * Load a symbols list from XML resource. 
     * 
     * @param id    XML resource ID 
     * @return      The symbols list 
     */ 
    private ArrayList<String> getXmlfile(int id) {
5
CodeRank
This code example shows how to use the following methods:close
 
	public void execute(int resId, XmlHandler handler) throws XmlHandler.XmlHandlerException {
	    final XmlResourceParser parser = mRes.getXml(resId);
	    try { 
		    handler.setLocalSync(true);
	        handler.parseAndApply(parser, mResolver);
	    } finally { 
	        parser.close();
	    } 
	} 
 
	public void execute(Context context, String assetName, XmlHandler handler) throws XmlHandler.XmlHandlerException {
		try { 
			final InputStream input = context.getAssets().open(assetName);
			final XmlPullParser parser = ParserUtils.newPullParser(input);
		    handler.setLocalSync(true);
			handler.parseAndApply(parser, mResolver);
		} catch (XmlHandler.XmlHandlerException e) {
			throw e;
		} catch (XmlPullParserException e) {
5
CodeRank
This code example shows how to use the following methods:getAttributeValue
 
    static final int BACKGROUND_COLOR = 0xffffffff;
 
    static abstract class ClockPalette { 
        public static ClockPalette parseXmlPaletteTag(XmlResourceParser xrp) {
            String kind = xrp.getAttributeValue(null, "kind");
            if ("cycling".equals(kind)) {
                return CyclingClockPalette.parseXmlPaletteTag(xrp);
            } else { 
                return FixedClockPalette.parseXmlPaletteTag(xrp);
            } 
        } 
 
        public abstract int getBackgroundColor(); 
 
        // forAngle should be on [0.0,1.0) but 1.0 must be tolerated 
        public abstract int getSecondColor(float forAngle);
 
        public abstract int getMinuteColor(float forAngle);
 
5
CodeRank
This code example shows how to use the following methods:next, nextTag, nextText
	 
	public SpeechPack(Context context, int xmlResId) {
		parser = context.getResources().getXml(xmlResId);
		 
		try { 
			parser.next();                // BEGIN_DOC
			parser.nextTag();             // BEGIN TAG RESOURCES
			parser.nextTag();             // BEGIN TAG ITEM (intro)
			 
			intro = parser.nextText();    // END TAG ITEM (intro)
			 
			parser.nextTag();             // BEGIN TAG ITEM (tutorial)
			 
			tutorial = parser.nextText(); // END TAG ITEM (tutorial)
			 
			parser.nextTag();             // BEGIN TAG ITEM (list)
			 
			list = parser.nextText();
		} 
		catch (Exception e) {

5
CodeRank
This code example shows how to use the following methods:getAttributeResourceValue, getAttributeValue
     * @param name  The attribute name 
     * 
     * @return  The value of the attribute 
     */ 
    private String getXmlAttribute(XmlResourceParser xrp, String name) {
        int resId = xrp.getAttributeResourceValue(null, name, 0);
        if (resId == 0) {
            return xrp.getAttributeValue(null, name);
        } else { 
            return mWnn.getString(resId);
        } 
    } 
 
    /** 
     * Load a symbols list from XML resource. 
     * 
     * @param id    XML resource ID 
     * @return      The symbols list 
     */ 
    private ArrayList<String> getXmlfile(int id) {
5
CodeRank
This code example shows how to use the following methods:close
    } 
 
    public void execute(int resId, XmlHandler handler) throws HandlerException {
        final XmlResourceParser parser = mRes.getXml(resId);
        try { 
            handler.parseAndApply(parser, mResolver);       
        } finally { 
            parser.close();
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:close
 
    public void execute(int resId, XmlHandler handler) throws XmlHandlerException {
        final XmlResourceParser parser = mRes.getXml(resId);
        try { 
        	handler.setLocalSync(true);
            handler.parseAndApply(parser, mResolver);
        } finally { 
            parser.close();
        } 
    } 
     
    public void execute(Context context, String assetName, XmlHandler handler) throws XmlHandlerException {
		try { 
		    final InputStream input = context.getAssets().open(assetName);
		    final XmlPullParser parser = ParserUtils.newPullParser(input);
        	handler.setLocalSync(true);
		    handler.parseAndApply(parser, mResolver);
		} catch (XmlHandlerException e) {
		    throw e;
		} catch (XmlPullParserException e) {
5
CodeRank
This code example shows how to use the following methods:close
    } 
 
    public void execute(int resId, XmlHandler handler) throws HandlerException {
        final XmlResourceParser parser = mRes.getXml(resId);
        try { 
            handler.parseAndApply(parser, mResolver);
        } finally { 
            parser.close();
        } 
    } 
} 
5
CodeRank

Related Android XmlResourceParser Questions & Answers:

See Code Examples for Android XmlResourceParser Methods: