Theoretical question: load external XML-Layout file in Android

Viewed 4572

I thinks it's probably not possible for security reason but just want to be sure: is it possible to create layout in Android from an external XML file?

To be exactly: I'm creating XML output with XSL on a remote server. I could create the necessary layout direct on the server and then download it to my Android App.

5 Answers

it's possible, but I found way to load only simple layout:

Resources resources=context.getPackageManager().getResourcesForApplication(targetPackage);
int resID = resources.getIdentifier("widget_layout" , "layout", TARGET_PACKAGE);
XmlResourceParser parser = resources.getLayout(resID);
View themeLayout = LayoutInflater.from(this).inflate(parser, null);
Related