![](http://c.hiphotos.baidu.com/album/s%3D400%3Bq%3D90/sign=b773e01b51da81cb4ae682cd625da12b/359b033b5bb5c9ea0fd30b0cd539b6003af3b338.jpg?v=tbs)
在Fragment里异步加载。
application已经设了全局变量
public static void initImageLoader(Context context) {
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
...
.build();
//全局初始化此配置
ImageLoader.getInstance().init(config);
}
在fragment里调用的getView是这样的:
public View getView(int arg0, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
try{
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = getLayoutInflater(bundle).inflate(R.layout.grid_view, parent, false);
viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView00);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Log.e("UIL",image[arg0]);
ImageLoader.getInstance().displayImage(image[arg0], viewHolder.imageView);
}catch(Exception e){
e.getStackTrace();
Log.e("UIL","报错");
}
return convertView;
}
class ViewHolder {
ImageView imageView;
}
}
已经搞了两天了还是不知道怎么解决
application已经设了全局变量
public static void initImageLoader(Context context) {
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
...
.build();
//全局初始化此配置
ImageLoader.getInstance().init(config);
}
在fragment里调用的getView是这样的:
public View getView(int arg0, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
try{
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = getLayoutInflater(bundle).inflate(R.layout.grid_view, parent, false);
viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView00);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Log.e("UIL",image[arg0]);
ImageLoader.getInstance().displayImage(image[arg0], viewHolder.imageView);
}catch(Exception e){
e.getStackTrace();
Log.e("UIL","报错");
}
return convertView;
}
class ViewHolder {
ImageView imageView;
}
}
已经搞了两天了还是不知道怎么解决