当在listview或者viewpager使用adapter填充图片时,使用glide报错问题(tag问题)

来源:互联网 发布:png压缩 centos 编辑:程序博客网 时间:2024/05/21 19:51

当在listview或者viewpager使用adapter填充图片时,使用glide报错问题
为题如下

涉及tag问题的报错

原代码

ImageView iv = new ImageView(mContext);Glide.with(UIUtils.getContext())            .load(DataUrl.imageUrl + topData.get(position))            .into(iv);

改之后的代码

View view = View.inflate(ProductDetails.this, R.layout.productdes_item, null);            ImageView imageView = (ImageView) view.findViewById(R.id.imageView);            container.addView(view);            // 设置缩放类型            imageView.setScaleType(ScaleType.FIT_XY);            Glide.with(UIUtils.getContext())            .load(DataUrl.imageUrl + topData.get(position))            .into(imageView);            /*imageView.setBackgroundResource(topData.get(position));*/            return view;

其中R.layout.productdes_item的代码如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <ImageView         android:id="@+id/imageView"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:scaleType="fitXY"/>     <!--  android:layout_marginLeft="10dp"        android:layout_marginRight="10dp"        android:layout_marginTop="5dp"        android:layout_marginBottom="5dp" --></LinearLayout>
0 0
原创粉丝点击