Android - Parsing XML resource references
I'm writing a game in Android that uses a custom XML format to describe the game levels. The level files are stored in res/xml
. I want to be able to reference Android resources (e.g., @string
and @drawable
). Since I'm parsing the XML m开发者_开发技巧yself, I'll obviously need to do this manually. So the question is: does Android have a public API for obtaining resources this way?
You can put the name of the strings/drawables in and use Resources.getIdentifier in your code. You can access your Resources
by using Context.getResources()
.
精彩评论