Renaud Favier
Renaud Favier

Reputation: 401

android-query, downloading images for a listView

I'm using android query to download an image in each element of a listview, and downloading thoses images is very, very, very slow (images far from heavy). I'm like having an image appearing each 5 minutes or so.. First i'm surprise we've got to instanciate one object AQuery for each convertView, I suppose that lib doesn't queu threads this way.. If someone knows a better lib, I could also be intrested

I don't know what I'm doing wrong and I hope someone could help !

here is the code of my adapter :

private class MainPagerListViewAdapter extends BaseAdapter {

    private ArrayList<Event> dataList;
    private LayoutInflater inflater;
    private Context context;

    public MainPagerListViewAdapter(Context context,
            ArrayList<Event> dataList) {

        this.inflater = LayoutInflater.from(context);
        this.dataList = dataList;
        Collections.sort(dataList, new ALaUneSort());
        this.context = context;
    }

    @Override
    public int getCount() {
        return dataList.size() + 1;
    }

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

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

    @Override
    public View getView(int position,  View convertView, ViewGroup parent) {

        convertView = inflater.inflate(R.layout.main_pager_basic_fragment_item_layout, null);
        AQUtility.setDebug(true);
        AQuery aq = new AQuery(convertView);
        String thumbnail = dataList.get(position-1).file;
        aq.id(R.id.imageView).progress(R.id.progress).image(thumbnail, true, true, 0, 0, null, AQuery.FADE_IN);

        return convertView;
    }

Thanks !

Renaud

Upvotes: 1

Views: 3992

Answers (2)

sunil
sunil

Reputation: 6614

i think you can use the ImageDownloader from here

Multithreading scenario explained here

Upvotes: 1

Dipak Keshariya
Dipak Keshariya

Reputation: 22291

Please see below Lazy Loading listview's source link for that, it may help you.

Lazy Loading Listview

Upvotes: 2

Related Questions