You must inflate view hierarchies (and menus, and other such things)
from XML resources because the resource compiler does a lot of pre-
processing of the original XML file to provide much more efficient
parsing of the device.  In general, the resource-based XML parser is
10x-100x faster than a native XML parser running on the device for a
generic XML file, and that doesn't even take into account all of the
fancy things it provides like pre-conversion of strings to integers
and resource references, batch retrieval of attributes, etc.

On Oct 2, 12:40 pm, kingkung <[EMAIL PROTECTED]> wrote:
> I'm trying to convert an Xml string into a view by parsing out the
> attributes into a set, and keep getting the following exception...
>
> java.lang.ClassCastException: android.util.XmlPullAttributes
>
> is called whenever I attempt to call Xml.asAttributeSet(XmlPullParser
> parser).
>
> Code below:
>
>    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
>    factory.setNamespaceAware(true);
>    XmlPullParser xpp = factory.newPullParser();
>    Log.d("ABC","**********");
>    xpp.setInput(new StringReader(XML_STRING));
>    int eventType = xpp.getEventType();
>    while (eventType!=XmlPullParser.END_DOCUMENT)
>         eventType = xpp.next();
>    try
>    {
>                 View v = new View(this,Xml.asAttributeSet(xpp));
>                 setContentView(v);
>     }
>    catch (Exception e)
>     {
>                 Log.d("ERROR","EXCEPTION:"+e);
>     }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to