1
您好我正在使用此设置一个位图到ImageView的返回null:decodeResource当选项被添加
o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
o.inDither = false;
o.inPurgeable = true;
o.inInputShareable = true;
b = BitmapFactory.decodeResource(getApplicationContext()
.getResources(), resourceId);
//Note the Options parameter is ignored
ivWallpaper = (ImageView) findViewById(R.id.ivWallpaper);
ivWallpaper.setImageBitmap(b);
ivWallpaper.setOnClickListener(Wallpapers.this);
工作正常,但是当我添加的选项参数:
o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
o.inDither = false;
o.inPurgeable = true;
o.inInputShareable = true;
b = BitmapFactory.decodeResource(getApplicationContext()
.getResources(), resourceId, o);
ivWallpaper = (ImageView) findViewById(R.id.ivWallpaper);
ivWallpaper.setImageBitmap(b);
ivWallpaper.setOnClickListener(Wallpapers.this);
它给我在nullPointerException: ivWallpaper.setImageBitmap(b);
请帮我一把。一直在努力解决这个问题了几个小时
这非常简单。谢谢。 –
@InnenTensai:如果这个答案回答了你的问题,考虑接受它会给海报带来15分。 1 +从我投票。 **编辑**没关系 - 你只是做到了!不错的演出! –