@
fangzhzh 1,只有一种类型的item,所有就不用重写viewtype的两个方法了
2,有else for if
3,,,
代码大概结构如下(异步加载图片的方法里用一个回调方法):
@
Override public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder;
family = listData.get(position);
if (convertView == null) {
holder = new ViewHolder();
convertView = mLayoutInflater.inflate(rsid, parent, false);
holder.familyFace = (ImageView) convertView
.findViewById(R.id.familyCardFace);
holder.familyName = (TextView) convertView
.findViewById(R.id.familyCardName);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.familyName.setText(family.getName());
cache.loadBitmaps(holder.familyFace, family.getPortrait(), null,
new SetImageCallBack() {
@
Override public void setImage(ImageView imageView, Bitmap bitmap) {
// TODO Auto-generated method stub
Bitmap bitmap1 = BitmapUtils.centerSquareScaleBitmap(
bitmap, GRIDSIZE);
imageView.setImageBitmap(bitmap1);
}
});
return convertView;
}
@
Override public int getCount() {
// TODO Auto-generated method stub
return listData.size();
}
@
Override public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@
Override public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}