无法将图像从原始图像加载到图像视图

Jov*_*van 2 android android-studio

我想使用 setImageResource 加载图像,从原始文件夹到 imageview,但我收到 Expected Resource of type Drawable 错误。

我正在使用 android studio,之前我使用 Eclipse 时一切都很好。我不想使用可绘制文件夹。

错误

原始文件夹:

我的项目中的 raw 文件夹

有什么建议吗?谢谢

小智 5

你可以尝试一下

   InputStream imageStream = this.getResources().openRawResource(R.raw.name);
   Bitmap bitmap = BitmapFactory.decodeStream(imageStream);
   imageview.setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)