我有延迟将图像加载到ImageViews的问题。当我向下滚动时,我看到顶部的图像(重复),当下载新图像时,将其替换为新图像。如何在新图像上显示ProgressBar,并在下载后用图像替换它?
这是来自LazyAdapter的getView():
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.item, null);
ImageView image=(ImageView)vi.findViewById(R.id.image);
imageLoader.DisplayImage(data[position], image);
return vi;
}
和item.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ProgressBar android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center"/>
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:minHeight="300px"
/>
</FrameLayout>
imageLoader.DisplayImage is asyncTask。
答案 0 :(得分:2)
您需要将图像路径设置为ImageView的标记。
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.item, null);
ImageView image=(ImageView)vi.findViewById(R.id.image);
image.setTag(data[position]);
imageLoader.DisplayImage(data[position], image);
return vi;
}