首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >异常:资源$NotFoundException:资源ID #0x4

异常:资源$NotFoundException:资源ID #0x4
EN

Stack Overflow用户
提问于 2011-11-01 18:53:48
回答 2查看 625关注 0票数 0

我需要放大图像,我使用了下面的代码

代码语言:javascript
复制
  int imageId =  (Integer) intent.getExtras().get(ProfilePageNormalUser.class.getName());
  imageView = (ImageView)findViewById(R.id.imageviewEnlarged);
  System.out.println("*********"+imageId);

  InputStream is = this.getResources().openRawResource(imageId);
  Bitmap originalBitmap = BitmapFactory.decodeStream(is);
  Matrix imageMatrix = new Matrix(); imageMatrix.postRotate(90);
  Bitmap scaledBitmap = Bitmap.createBitmap(originalBitmap, imageView.getWidth(), imageView.getHeight(), originalBitmap.getWidth(), originalBitmap.getHeight(), imageMatrix, false);
  imageView.setImageBitmap(scaledBitmap);

但是给了我上面的例外。

代码语言:javascript
复制
         Resources$NotFoundException: Resource ID #0x4

谁能告诉我问题出在哪里。谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-11-01 19:31:20

我认为应该使用this.getResources().openRawResource(id)。您必须将您的资源移动到res/raw文件夹。

尝试在res文件夹下创建一个名为raw的文件夹,并将您的资源粘贴到那里。

让我知道它进行得怎么样..

票数 1
EN

Stack Overflow用户

发布于 2011-11-01 18:57:20

OpenRawResource无法从您正在使用的imageId中找到资源。

检查你的imageId。

你可以直接使用:我认为:InputStream ins = getResources().openRawResource(R.raw.my_db_file);

指定raw文件夹中如上所述的imageId。

首先像这样检查,它工作或不工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7965399

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档