0

If you check out this answer. Lazy load of images in ListView

Fedor has provided a tutorial on how to lazy load with image view. But he said it can be used with Gallery with minor modifications.

How do i go about doing this with minor modifications?

Ive Tried this so far.

This is the BaseAdapter public class LazyAdapter extends BaseAdapter {

private Activity activity;
private String[] data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 

public LazyAdapter(Activity a, String[] d) {
    activity = a;
    data=d;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.length;
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.item, null);

    TextView text=(TextView)vi.findViewById(R.id.text);;
    ImageView image=new ImageView(this.activity);
    text.setText("item "+position);
    imageLoader.DisplayImage(data[position], activity, image);
    return vi;
}

}

And then in my activity i do this..

    LazyAdapter adapter=new LazyAdapter(MainMenu.this, myRemoteImages);
 ((Gallery) findViewById(R.id.gallery))
                      .setAdapter(adapter);

It doesnt seem to be working though.

Nothing is showing up

Community
  • 1
  • 1
yoshi24
  • 3,147
  • 8
  • 45
  • 62

1 Answers1

0

Here is something that I managed to work out. After implementing Fedor's code in a GridView, you must be aware that in the ImageLoader class file there is a class named decodeFile(). In that class Fedor's code automatically resizez the image so that it can become a small thumbnail. You have just to comment the "rescaling" part and your image will appear in full in the GalleryView.

AnTz
  • 127
  • 3
  • 11