@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final Holder vh;
    if (convertView == null) {
      vh = new Holder();
      convertView = mInflater.inflate(R.layout.pic_item, null);
      vh.image = (ImageView) convertView.findViewById(R.id.url_image);

      convertView.setTag(vh);
    } else {
      vh = (Holder) convertView.getTag();
    }
    // 加载图片
    String url = list.get(position);

    com.nostra13.universalimageloader.core.ImageLoader.getInstance()
        .displayImage(
            url,
            vh.image,
            new SimpleImageLoadingListener() {
              @Override
              public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                String message = null;
                switch (failReason.getType()) {
                  case IO_ERROR:
                    message = "下载错误";
                    break;
                  case DECODING_ERROR:
                    message = "图片无法显示";
                    break;
                  case NETWORK_DENIED:
                    message = "网络有问题,无法下载";
                    break;
                  case OUT_OF_MEMORY:
                    message = "图片太大无法显示";
                    break;
                  case UNKNOWN:
                    message = "未知的错误";
                    break;
                }
              }
            });

    return convertView;
  }
Example #2
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   // TODO Auto-generated method stub
   Holder holder;
   if (convertView == null) {
     holder = new Holder();
     convertView = inflater.inflate(R.layout.category_item, parent, false);
     holder.image = (NetworkImageView) convertView.findViewById(R.id.img);
     holder.name = (TextView) convertView.findViewById(R.id.name);
     convertView.setTag(holder);
   } else {
     holder = (Holder) convertView.getTag();
   }
   holder.name.setText(categories.get(position).getName());
   Log.d("imgurl", "http://52.74.244.5:8080/" + categories.get(position).getImagePath());
   String StrImageUrl = Constants.CATEGORY_IMAGE_URL + categories.get(position).getImagePath();
   makeImageRequest(holder.image, StrImageUrl);
   return convertView;
 }