Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Theoretical question: load external XML-Layout file in Android

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.

like image 315
Radek Suski Avatar asked Jul 04 '11 20:07

Radek Suski


3 Answers

It is impossible. XML layouts in Android are NOT stored as XML. For performance reasons, they are pre-processed during compilation and stored in binary form, and layout inflater only understands that binary form rather than xml.

like image 141
Jarek Potiuk Avatar answered Nov 06 '22 07:11

Jarek Potiuk


Of course you can create Views dynamic at runtime, while I'm not shure, that this is the best solution. If you have a look at the internals of Android, every View which is created through XML is called with a Constructor with two parameters: Context and - even more interesting for you - an AttributeSet. I think you have a lot of work with parsing it, while keeping track of the right format. You could at least set the values and build your views yourself in Java depending on Server output.

like image 29
Rafael T Avatar answered Nov 06 '22 08:11

Rafael T


YES, right now is possible with ItsNat Droid, take a look:

https://groups.google.com/forum/#!topic/itsnat/13nl0P12J_s

It is still under heavy development but most important features are already implemented.

like image 30
jmarranz Avatar answered Nov 06 '22 07:11

jmarranz