Eitan F
Eitan F

Reputation: 127

Layouts in Android SDK

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

Answers (1)

2red13
2red13

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

Related Questions