【发布时间】:2011-08-11 17:39:27
【问题描述】:
我的 Drawable-mdpi 文件夹中有一个名为 (my_image.png) 的图像。
我的 android 应用程序与 web 服务交互。它可能会发回“my_image”。我的 android 应用程序应该会加载这张图片。
我正在使用 Monodroid,我试过了
int abc = Resources.GetIdentifier("my_image","drawable",null);
然而结果总是"0"。什么时候应该(从资源文件)
// aapt resource value: 0x7f020000
public const int my_image = 2130837504;
环顾四周,android的方式好像也差不多
int i = this.getResources().getIdentifier("txt_asecondtext", "strings", this.getPackageName());
我尝试传入包名而不是 null,但没有任何效果。
【问题讨论】:
-
我相信我明白了为什么您的最后一个示例行不起作用。
strings应该是string