Is there a way to have a Resource name inside strings.xml with a space?

99封情书 提交于 2021-01-29 03:02:44

问题


Example:

Android complains that ' ' is not a valid resource name character.

Am I forced to use say "New_Delhi" and then programatically map this in my program?


回答1:


Yes, for the simple reason that Java fields cannot have spaces in their names. A string resource named New_Delhi is referenced in Java as R.string.New_Delhi. A space, in lieu of the underscore, would not be valid Java syntax.



来源:https://stackoverflow.com/questions/36483076/is-there-a-way-to-have-a-resource-name-inside-strings-xml-with-a-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!