Reputation: 1084
I have problem with lazy loading images to ImageViews. When i scroll down, i see images from top (dupliacated), when new image is downloaded its replaced with new one. How can i show on new images ProgressBar, and replace it with images when its downloaded?
Here is my getView() from LazyAdapter:
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;
}
and 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 its asyncTask.
Upvotes: 0
Views: 144
Reputation: 7849
You need to set the image path to tags for 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;
}
Upvotes: 2