Reputation: 127
Is there a way to load an XML Layout without the R class? And if possible to load it from a string?
Upvotes: 0
Views: 108
Reputation: 11217
Yes, eg if you want to load a xml from the web and inflate it to ViewGroup.
Use (LayoutInflater) mInflater = LayoutInflater.from(context);
and inflate from a xml:
mInflater.inflate(XmlPullParser parser, ViewGroup root)
you will be able to load the xml from the web by performing a webrequest and use the DocumentBuilder
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
Document doc = db.parse([INPUT_STREAM]);
....
Upvotes: 2