You can use the index ie position and get the item from the list.
Store all the ids of images in a list or a Array. Pass the list or array to the constructor of adapter class.
int[] myImageList = new int[]{R.drawable.thingOne, R.drawable.thingTwo};
Pass the array to the constuctor of adapter class
in[] imgid;
public TowarAdapter(Activity context, int resource, int[] imgid)
{
super(context, resource);
this.imgid = imgid
}
public int getCount() {
// TODO Auto-generated method stub
return imgid.length();
}
Then in getView
view.ivTowar.setImageResouce(imgid[i]);