我有一个GridView,我使用我的适配器设置图像,我使用Universal Image Loader库从网址加载图像,现在一切都很好,但我想把一个gif加载器放到每个网格项的背景,直到该特定gridItem中的图像未加载,任何好友请建议我如何做到这一点,我的代码如下:
适配器代码
package com.eps.fortalented.adapter;
import java.util.ArrayList;
import java.util.HashMap;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.eps.fortalented.R;
import com.eps.fortalented.uc.GifWebView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
public class photosTalentAdapter extends BaseAdapter {
public ArrayList<HashMap<String, String>> photoArray;
private Context mContext;
private DisplayImageOptions options;
public static ImageLoader imageLoader;
String photoImg;
String query = "http://test.fortalented.com/manage/";
Intent i;
String camera, description, captured_date, date_modified, category,
date_added, candidate_name, big_img;
GifWebView view;
@SuppressWarnings({ "deprecation" })
public photosTalentAdapter(Context paramContext,
ArrayList<HashMap<String, String>> photoList) {
this.mContext = paramContext;
this.photoArray = photoList;
imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(paramContext));
options = new DisplayImageOptions.Builder().cacheOnDisc(true)
.showStubImage(R.drawable.noimage)
.showImageOnFail(R.drawable.noimage).build();
// New
}
public int getCount() {
return this.photoArray.size();
}
public Object getItem(int paramInt) {
return Integer.valueOf(paramInt);
}
public long getItemId(int paramInt) {
return paramInt;
}
public View getView(final int paramInt, View paramView,
ViewGroup paramViewGroup) {
LayoutInflater localLayoutInflater = (LayoutInflater) this.mContext
.getSystemService("layout_inflater");
Viewholder localViewholder = null;
if (paramView == null) {
paramView = localLayoutInflater.inflate(R.layout.raw_photo_talent,
paramViewGroup, false);
localViewholder = new Viewholder();
localViewholder.iv_photo = ((ImageView) paramView
.findViewById(R.id.iv_photo));
localViewholder.rl_zoom = ((RelativeLayout) paramView
.findViewById(R.id.rl_zoom));
paramView.setTag(localViewholder);
} else {
localViewholder = (Viewholder) paramView.getTag();
}
imageLoader.displayImage(
query + photoArray.get(paramInt).get("thumbnail"),
localViewholder.iv_photo, options);
return paramView;
}
static class Viewholder {
ImageView iv_photo;
RelativeLayout rl_zoom;
}
}