Android:带有数字的可绘制资源。是否可以?
我想知道我是否可以以某种方式创建一个名为 787.png 的可绘制资源(例如 png)。因为 Eclipse 不会让我编译该项目,除非我修改它。
提前致谢。
I would like to know if i can, somehow, create a drawable resource (png for example) called 787.png. Because Eclipse wont let me compile the project unless i modify it.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
资源不能使用数字名称的原因是变量名称不能以数字开头。对于每个资源,都会生成一个带有资源名称的常量变量(在 R.java 中)。如果你查看你的 Eclipse 项目,在“gen”文件夹下你会看到 R.java
据我所知,在 android 项目中不可能有纯数字名称的资源。
如果您解释为什么需要数字资源,也许我们可以提供替代解决方案
The reason you can't have a resource with a numeric name is because variable names cannot start with numbers. For each resource, there is a generated constant variable (in R.java) with the resource's name. If you look in your Eclipse project, under the "gen" folder you will see R.java
It is my understanding that it is not possible to have a resource with a pure numeric name in an android project.
If you explain why you require a numeric resource, maybe we can provide alternative solutions
简短的回答是否定的,
Drawable资源图片名称必须是起始字符
喜欢作为
R.drawable.abc。 // 正确的
R.drawable.123 //错误
Short Answer is NO,
Drawable resource image name must be start character
Like as
R.drawable.abc. // right
R.drawable.123 //wrong
所以你不能有一个以数字开头的可绘制对象,例如:
49ers
,但你可以有这个_49ers
,这是可以预料的。So you can NOT have a drawable that starts with a number , ex:
49ers
BUT you can have this_49ers
which is expectable.