开发者

Android - Parsing XML resource references

开发者 https://www.devze.com 2023-03-20 14:58 出处:网络
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 @dr

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().

0

精彩评论

暂无评论...
验证码 换一张
取 消