package com.example.adapter;
import com.example.imageload.R;
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
public class MyAdapter extends BaseAdapter {
// DisplayImageOptions options = new DisplayImageOptions.Builder()
// .showImageForEmptyUri(R.drawable.ic_launcher)
// .bitmapConfig(Bitmap.Config.RGB_565)
// .showImageOnFail(R.drawable.icon_head)
// // 图片加载中,显示的默认图片
// .showImageOnLoading(R.drawable.bar1)
// .showImageForEmptyUri(R.drawable.icon_head).build();
private String [] str;
private Context context;
public MyAdapter(String[] str, Context context) {
super();
this.str = str;
this.context = context;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return str.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder vh;
if(convertView==null){
vh=new ViewHolder();
convertView=View.inflate(context, R.layout.item_layout, null);
vh.iv=(ImageView) convertView.findViewById(R.id.iv);
convertView.setTag(vh);
}else{
vh=(ViewHolder) convertView.getTag();
}
ImageLoader.getInstance().displayImage(str[position], vh.iv);
return convertView;
}
static class ViewHolder{
ImageView iv;
}
}
ImageLoader-----适配器
最新推荐文章于 2024-04-26 19:04:05 发布