Android 无法获取ResourceID

Android 无法获取ResourceID,android,.net,Android,.net,我有一个微调器,它根据列表中的选定项设置图像视图资源。问题是,当我去检索资源ID时,我总是返回一个0或未知成员 所选微调器项() private void微调器\u ItemSelected(对象发送器,AdapterView.ItemSelectedEventArgs e){ 微调器微调器=(微调器)发送器; stringtoast=string.Format(“{0}”,spinner.GetItemAtPosition(e.Position)); var imageView=findvie

我有一个微调器,它根据列表中的选定项设置图像视图资源。问题是,当我去检索资源ID时,我总是返回一个0或未知成员

所选微调器项()

private void微调器\u ItemSelected(对象发送器,AdapterView.ItemSelectedEventArgs e){
微调器微调器=(微调器)发送器;
stringtoast=string.Format(“{0}”,spinner.GetItemAtPosition(e.Position));
var imageView=findviewbyd(Resource.Id.stateView);
var-resourceId=0;
resourceId=Resources.GetIdentifier(toast,“可绘制”,PackageName);
SetImageResource(resourceId);
Toast.MakeText(this,Toast,ToastLength.Long).Show();
}
我已经尝试了Resource.GetIdentifier的所有组合(string,string,string),但是我没有任何运气

资源位于resource.Designer.cs中,在调试时,如果我将资源id的值编辑为resource.Designer.Drawable中项的id之一,则函数将按预期工作


有人知道我做错了什么吗?

从来没有使用过Mono Android,如果您已经尝试过,请道歉,但是。。。您确定为Resources.GetIdentifier匹配了正确的语法吗?您是否也尝试过“drawable.png”(或任何扩展名)而不是“drawable”

**编辑:

在普通的Android上,我相信在视图就位之前资源不会膨胀,在屏幕上显示资源ID之前资源ID是无效的。为了设置imageView的源,我们使用一些静态的东西,比如

imageView.setBackgroundResource(R.drawable.splash_screen);
其中“splash_screen.png”是存储在res/drawable small下的文件/

不确定您是否已双重检查了文件名,并且该文件是否位于正确的文件夹中

imageView.setBackgroundResource(R.drawable.splash_screen);