1

I want to use external(like /storage/sdcard0/main.xml) xml as Layout by LayoutInflater. So I found use external xml by XmlPullParser. But It didn't work!!

How to write xml source which is operating on XmlPullParser and LayoutInflater?

1
  • could you post your code? Commented Nov 3, 2013 at 14:49

1 Answer 1

3

LayoutInflater does not work on arbitrary xml at runtime. See the comment on LayoutInflater.inflate.

Important For performance reasons, view inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use LayoutInflater with an XmlPullParser over a plain XML file at runtime.

The platform performs a downcast in Resources.java that makes this assumption.

// XXX note that for now we only work with compiled XML files.
// To support generic XML files we will need to manually parse
// out the attributes from the XML file (applying type information
// contained in the resources and such).
XmlBlock.Parser parser = (XmlBlock.Parser)set;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.