0

我有一个我正在显示的图像列表,使用通用图像加载器,现在我试图在位置 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;
}
4

1 回答 1

0

广告的位置有问题,需要在 ad1 上 +1 和在 ad2 上 +2。

于 2014-06-29T08:10:45.470 回答