このコードは、画像とテキストビューを含むリストビューをロードし、それを参照して使用できるように編集します(レイジーアダプターからのサンプルコード)
public class abcdadapter extends BaseAdapter {
private Activity activity;
private String[] data;
private ArrayList<HashMap<String, String>> dat;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public abcdadapter(Activity a, ArrayList<HashMap<String, String>> save,String[] images) {
activity = a;
dat=save;
data=images;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public static class ViewHolder{
public TextView text;
public ImageView image;
}
public View getView(int position, View convertView, ViewGroup parent) {
return parent;
View vi=convertView;
ViewHolder holder;
if(convertView==null){
vi = inflater.inflate(R.layout.item, null);
holder=new ViewHolder();
holder.text=(TextView)vi.findViewById(R.id.text);
holder.image=(ImageView)vi.findViewById(R.id.image);
vi.setTag(holder);
}
else
holder=(ViewHolder)vi.getTag();
holder.text.setText(dat.get(position).get("NAME"));
// holder.image.setTag(data[position]); // set your image from drawable
// imageLoader.DisplayImage(data[position], activity, holder.image);
return vi;
}