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