SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItem, R.layout.items_list, new String[] { "imagePath", "name", "njname", "length", "id" }, new int[] { R.id.imagePath, R.id.name, R.id.njname, R.id.length, R.id.hiddenId });
第一步:设置listItemAdapter
listItemAdapter.setViewBinder(new CustomViewBinder());
第二步:
import android.graphics.Bitmap; import android.view.View; import android.widget.ImageView; import android.widget.SimpleAdapter.ViewBinder; public class CustomViewBinder implements ViewBinder { 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; } }
时间: 2024-10-16 20:06:05