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.

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

do you know any library that handles parsing-generating layout?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.