我有一个我正在使用通用图片加载器显示的图片列表,现在我试图在位置4之间放置广告,但此广告正在替换该位置的图片。当看到位置和网址时,一切似乎都没问题。自定义适配器有问题吗?或者是否可以在xml中执行某些操作?
@Override
public View getView(int position, View convertView, ViewGroup parent) {
int type = getItemViewType(position);
System.out.println(position+" "+urls.get(position));
if (convertView == null)
{
holder = new ViewHolder();
switch (type)
{
case TILBUD:
convertView = mInflater.inflate(R.layout.image_row, null);
holder.imageView = (ImageView)convertView.findViewById(R.id.image_row);
imageLoader.displayImage(urls.get(position), holder.imageView, options);
break;
case AD_SPACE_1:
convertView = mInflater.inflate(R.layout.ad_space_row_1, null);
adSpace1 = (AdSpace)convertView.findViewById(R.id.ad_row_1);
adSpace1.setSID(returnSID(store, "ad1"));
adSpace1.setAdEventListener(adEventListener);
adSpace1.setAdErrorEventListener(adErrorListener);
adSpace1.setAdAnimationEventListener(adAnimationListener);
adSpace1.setAdMediaEventListener(adMediaEventListener);
holder.adSpace1 = adSpace1;
adSpace1.runAd();
break;
case AD_SPACE_2:
convertView = mInflater.inflate(R.layout.ad_space_row_2, null);
adSpace2 = (AdSpace)convertView.findViewById(R.id.ad_row_2);
adSpace2.setSID(returnSID(store, "ad2"));
adSpace2.setAdEventListener(adEventListener);
adSpace2.setAdErrorEventListener(adErrorListener);
adSpace2.setAdAnimationEventListener(adAnimationListener);
adSpace2.setAdMediaEventListener(adMediaEventListener);
holder.adSpace2 = adSpace2;
adSpace2.runAd();
break;
}
convertView.setTag(holder);
}
else
{
holder = (ViewHolder)convertView.getTag();
}
return convertView;
}
}
public static class ViewHolder
{
public ImageView imageView;
public AdSpace adSpace1, adSpace2;
}
答案 0 :(得分:0)
广告的位置有问题,ad1需要+1,ad2需要+2。