a179583637
a179583637
2016-06-23 10:59

重写SimpleAdapter以让其中的imageview显示bitmap,怎么解决

下面是我重写simpleadapter的代码,其主要作用是显示返回的bitmap图片,求大神看看哪里不对
if (msg.arg1 == 0X456) {
listItems= (List>) msg.obj;
// 创建一个SimpleAdapter实现界面的更新
SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), listItems, R.layout.news_simple_item,
new String[]{"image", "title", "abs"},
new int[]{R.id.image, R.id.title, R.id.abs});
simpleAdapter.setViewBinder(new SimpleAdapter.ViewBinder(){

                @Override
                public boolean setViewValue(View view, Object data,
                                            String textRepresentation) {
                    if( (view instanceof ImageView) & (data instanceof Bitmap) ) {
                        ImageView iv = (ImageView) view;
                        Bitmap bm = (Bitmap) data;
                        iv.setImageBitmap(bm);
                        return true;
                    }
                    return false;

                }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答