android ListView 中的ImageView显示Drawable类型的图

使用SimpleAdapter中的ViewBinder方法实现

 

SimpleAdapter notes=new SimpleAdapter(this,list,R.layout.info_row,

                 new String[]{"img","name","desc"},new int[]{R.id.img,R.id.name,R.id.desc});

         

         itemlist.setAdapter(notes);

         notes.setViewBinder(new ViewBinder(){

             public boolean setViewValue(View view,Object data,String textRepresentation){

                 if(view instanceof ImageView && data instanceof Drawable){

                     ImageView iv=(ImageView)view;

                     iv.setImageDrawable((Drawable)data);

                     return true;

                 }

                 else return false;

             }

         });

  

 

 

posted @ 2012-05-17 12:35  坏混混  阅读(337)  评论(0编辑  收藏  举报