Android:带有数字的可绘制资源。是否可以?

发布于 2024-11-30 02:56:20 字数 93 浏览 4 评论 0原文

我想知道我是否可以以某种方式创建一个名为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橘和柠 2024-12-07 02:56:20

资源不能使用数字名称的原因是变量名称不能以数字开头。对于每个资源,都会生成一个带有资源名称的常量变量(在 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

此生挚爱伱 2024-12-07 02:56:20

简短的回答是否定的,
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

最近可好 2024-12-07 02:56:20

所以你不能有一个以数字开头的可绘制对象,例如: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文