views:

80

answers:

1

Hi, I would like ask if there's a way to download an android layout from the Internet into the "res/layout" folder.

I was thinking in getting the file using an HttpUrlConnection and a FileOutputStream, like discussed in here http://stackoverflow.com/questions/576513/android-download-binary-file-problems but I can't fgure out how to put it into the "res/layout" folder.

Thanks!

+3  A: 

Unfortunately the layouts in your 'res' directory are compressed at build time and include baked-in resource IDs that match your pre-built R.java. So it wouldn't be possible to take a new layout file at runtime and inflate it in the same way.

However layouts can be built up programatically (new Button() and so on), so you could probably make an XML format and reader that was quite similar to the standard layout format.

Jim Blackler
Your answer seems quite logical, I don't know why I didn't figure it out myself, thanks Jim!
oscarello
Good luck. This issue has come up before, it might be time for an open source library. I would do it myself now if I had a need for it.
Jim Blackler