最近在做android时碰到的问题,求大神帮助,先贴出必要的代码
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder viewHolder = null;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = mInflater.inflate(R.layout.listview_item, null);
//初始化对象
viewHolder.appImageView = (ImageView) convertView
.findViewById(R.id.content_app_image);
viewHolder.appNameView = (TextView) convertView
.findViewById(R.id.content_txt_name);
viewHolder.appLabelView = (TextView) convertView
.findViewById(R.id.content_txt_label);
viewHolder.appSimpleMarkView = (TextView) convertView
.findViewById(R.id.content_simple_mark);
viewHolder.appDownView = (ImageView) convertView
.findViewById(R.id.content_image_down);
convertView.setTag(viewHolder);
//绑定数据ClsCommonMethod.Base64ToImage(valueStrings[1].trim())
// viewHolder.appImageView.setImageDrawable((Drawable) mData.get(position).get("APP_PIC".toUpperCase()));
Bitmap bitmap = ClsCommonMethod.Base64ToImage(mData.get(position).get("APP_PIC".toUpperCase()).toString().trim());
if (bitmap!=null) {
viewHolder.appImageView.setImageBitmap(bitmap);
}
// viewHolder.appImageView.setImageBitmap(ClsCommonMethod.Base64ToImage(mData.get(position).get("APP_PIC".toUpperCase()).toString().trim()));
viewHolder.appNameView.setText(mData.get(position).get("app_name".toUpperCase()).toString().trim());
// viewHolder.appLabelView.setText(mData.get(position).get("app_name".toUpperCase()).toString().trim());
viewHolder.appSimpleMarkView.setText(mData.get(position).get("short_desc".toUpperCase()).toString().trim());
//下载
viewHolder.appDownView.setTag(mData.get(position).get("apk_address".toUpperCase()).toString().trim());
viewHolder.appDownView.setOnClickListener(new downLoadClickListener());
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
return convertView;
}
这是我自定义的一个listView适配器,代码在
if (bitmap!=null) {这里出错,报的错误是:
viewHolder.appImageView.setImageBitmap(bitmap);
}
调试之后发现:viewHolder.appImageView、bitmap都有值,,适配器的调用代码:
MyAppListAdapter appListAdapter = new MyAppListAdapter(this, list);
viewList.setAdapter(appListAdapter);
------解决思路----------------------
是否是报这句的错误了?
if (bitmap!=null) {
viewHolder.appImageView.setImageBitmap(bitmap);
}
直接 ImageView iv = viewHolder.appImageView;
看看iv的值