我的ListView不光滑我使用適配器ListView
這是實現getView
當我設置位圖的ImageView
@Override
public View getView(int position, View convertView, ViewGroup parent){
ItemViewHolder viewHolder;
if(convertView == null){
convertView = (RelativeLayout)inflater.inflate(resource,parent, false);
viewHolder = new ItemViewHolder();
viewHolder.itemTextName = (TextView)convertView.findViewById(R.id.item_name);
viewHolder.itemTextExpDate = (TextView)convertView.findViewById(R.id.item_exp_date);
viewHolder.itemImage = (ImageView)convertView.findViewById(R.id.item_image);
}
else{
viewHolder = (ItemViewHolder)convertView.getTag();
}
Item item = listItem.get(position);
if(listItem != null){
viewHolder.itemTextName.setText(item.getName());
viewHolder.itemTextExpDate.setText(""+item.getDaysleft());
viewHolder.itemImage.setImageBitmap(item.getImage());
}
return convertView;
}
static class ItemViewHolder {
View baseView;
TextView itemTextName;
TextView itemTextExpDate;
ImageView itemImage;
}
當我設置Bitmap
到ImageView
的ListView
並不順利。
我是否在getView
中實現了正確的代碼?