I got a thing to think about, but cannot find the solution. New layout file is being received from the server. I faced problem that Parser cannot resolve all those android attributes to inflate view in the next step. We can change file format on server-side to make it as attributes, but how to parse it and set properly still a question. Does anybody have any idea or suggestions how to do that? Thanks in advance.
Asked
Active
Viewed 1,577 times
1
-
You can't store files downloaded from server in the assets directory- assets are read only. – Gabe Sechan Mar 12 '15 at 18:32
-
@GabeSechan, ah, sure thing, I said it for example though. I'll correct now, thanks. – Yurets Mar 12 '15 at 18:35
1 Answers
2
You can't. Two problems.
1)You can't parse a general xml file and make a layout from it. From the docs on LayoutInflater.inflate() "Important 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."
2)You can't save to assets. Assets are read only. Of course you could use the filesystem instead.
You can get what you want, but you'd have to write your own parser for your layout files from scratch. Its highly not recommended.

Gabe Sechan
- 90,003
- 9
- 87
- 127
-
good answer, thanks! But okay, if I receive an attributes for UI elements and then generate Views and apply those elements to created Views? Example of a file: `` ? What if do it this way? – Yurets Mar 12 '15 at 18:41
-
You can do that. You'll have to do it entirely by hand, which will be slow. I suspect you'll find it a bad user experience, if you really want to do it this way I'd suggest just downloading HTML for display. – Gabe Sechan Mar 12 '15 at 18:45