我在 imageButton 上显示图像时遇到问题...
imgWeatherIcon = (ImageButton) findViewById(R.id.mndpImage);
Intent i = getIntent();
this.iconfile = i.getStringExtra("icon");
String uri = "drawable/"+ "d" + iconfile;
System.out.println("* "+ uri);
int imageBtnResource = getResources().getIdentifier(uri, null, getPackageName());
Drawable dimgbutton = getResources().getDrawable(imageBtnResource);
imgWeatherIcon.setImageDrawable(dimgbutton);
一些 System.out.println 输出:
uri = drawable/dsnowing
imageBtnResource = 2130837512
dimgbutton = android.graphics.drawable.BitmapDrawable@414733c8
图像存在于布局中 imageButton 元素 (mndpImage) 的可绘制文件夹名称是正确的
知道如何解决这个问题吗?