Is there a way to arbitrarily load Resources at runtime in Android?
Posted
by Omega
on Stack Overflow
See other posts from Stack Overflow
or by Omega
Published on 2010-03-07T22:30:33Z
Indexed on
2010/03/07
23:11 UTC
Read the original article
Hit count: 157
I've got some XML resources in my Android app. Each one has a different name like "bicycle.xml" and "car.xml". I'd like to know if there's a way to load resources based on conditions during run time.
As an example... Say I had a text input in my app. When the user enters "bicycle", my app can look up an XML resource by that name, parse and load it. Whereas if they enter "car", they would end up with the data from the other XML file.
I've noticed so far that to load resources, you have to use the autogenerated "R" class, which restricts you to hard-coding resources at compile time.
© Stack Overflow or respective owner