1

I want to load android XML layout file in my activity from sd card of my android device? Is this possible? Any help is appreciated.

Edit: Actually my requirements is to have layout on sd card so i can modify it whenever i want and the changes will show in my layout.

rajG
  • 53
  • 1
  • 2
  • 7

2 Answers2

1

Loading XML Layout File from SD CARD is simply impossible because

  1. XML Layout file resources need to generate id with R.java-Java Generated File which can be generated at compile time only. You can generate if you simple copy that XML Layoutfrom your SD-CARD to res/layout/ folder at time of writing your application

  2. R.java-Java Generated file is needed to wired up the Java code and XML Layout file. If you have used that XML Layout file resources e.g[Button,EditText etc..,] in your application.

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
  • can i get xml layout file from other apk file that was already on sd card?......just trying other option – rajG Jan 04 '13 at 10:15
  • @rajG you can definitely get the xml files from another apk package. `But they are just useless in your application`. As that `XML Layout File never been complied with your application.` – Vikalp Patel Jan 04 '13 at 10:47
  • @rajG May be these link help you in some way to achieve your goal : http://stackoverflow.com/questions/1001944/android-remote-code-loading – Vikalp Patel Jan 04 '13 at 10:52
1

Not possible, because xml layouts are compiled in a specific format. You would need to compile the xml and inject it in the apk, which is not feasible on the device itself.

njzk2
  • 38,969
  • 7
  • 69
  • 107