2

I am working on a project which will have lots and lots of Layout and Code changes. My Question is pretty simple but I don't know anything about it. Would it be possible to dynamically load content such as Source Code (Java) and XML Layout Files on a Backgroundthread and then startup another Activity with the downloaded Content (Of either/and Java File + XML Layout)? So that you change your Code and Layout online and download it on every start of the App?

Thanks alot in advance.

user754730
  • 1,341
  • 5
  • 31
  • 62

1 Answers1

2

You can load classes dynamically. But as for xml layouts that is hardly possible sobeit you are going to write your own parser and inflater. Unfortunately LayoutInflater can't inflate external files. This is from LayoutInflater documentation:

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.)

So you are basically restricted to create all your UI from the code only.

Community
  • 1
  • 1
Andrei Mankevich
  • 2,253
  • 16
  • 15