Unable to decode stream:
Java
.io.FileNotFoundException: /
Android
.graphics.Bitmap(或是 imageview XXXXX / D
rawable
)这类错误 可能是由于 使用的adapter不支持图形所导致的,需要从写Adapter ;
============
现在刚学android 好多东西还不是很清楚,所以在上面这个问题上纠结了 好几天 ,我使用的是SimpleAdapter ,而simpleAdapter 并不支持bitmap或是 imageview 默认的只是支持ImageView的id
要想使用SimpleAdapter支持imageView 或 bitmap
有两种方法:
一:
SimpleAdapter listAdapter = new SimpleAdapter( 参数省略);
-
listAdapter.setViewBinder(
new
ViewBinder() { -
@Override
-
public
boolean
setViewValue(View view, Object attentionList, String textRepresentation) { -
// TODO Auto-generated method stub
-
if
(view
instanceof
ImageView && attentionList
instanceof
Bitmap){ - ImageView iv=(ImageView)view;
- iv.setImageBitmap((Bitmap) attentionList);
-
return
true
; -
}
else
{ -
return
false
; - }
- }
- });
listAdapter.setViewBinder(new ViewBinder() {
@Override
public boolean setViewValue(View view, Object attentionList, String textRepresentation) {
// TODO Auto-generated method stub
if(view instanceof ImageView && attentionList instanceof Bitmap){
ImageView iv=(ImageView)view;
iv.setImageBitmap((Bitmap) attentionList);
return true;
}else{
return false;
}
}
});
二:就是重写 simpleadapter
仅是笔记而已