I am wondering if it is possible to inflate an Android activity from a NON compiled android XML layout file at runtime?
Asked
Active
Viewed 541 times
2
-
1what exactly you mean by "Non-compiled"? – Gagan Oct 26 '12 at 04:27
1 Answers
3
There is nothing built into the API that will allow you to do this. The inflater requires a pull parser that works off of compiled XML files. The system takes care of a lot of things like resource binding as part of the inflation processing. From the documentation for LayoutInflater
:
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; it only works with an XmlPullParser returned from a compiled resource (R.something file.)
I suppose that you could build your own XML handler and do it yourself, but it would be a lot of work.

Ted Hopp
- 232,168
- 48
- 399
- 521