0

I'm using a ViewPager with circle indicators for showing pictures.

I want to use the url of some images instead. Actually lazy load some images inside ViewPager with circle indicators. I have to change default image adapter to lazyloading adapter (which gets url of the images). Please help me with this.

The code for image adapter is this:

public class ImageAdapter extends BaseAdapter {

private LayoutInflater mInflater;
private static final int[] ids = { R.drawable.cupcake, R.drawable.donut, R.drawable.eclair, R.drawable.froyo,
        R.drawable.gingerbread, R.drawable.honeycomb, R.drawable.icecream };

public ImageAdapter(Context context) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {
    return ids.length;
}

@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) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.image_item, null);
    }
    ((ImageView) convertView.findViewById(R.id.imgView)).setImageResource(ids[position]);
    return convertView;
}

}

And Main activity uses this code to lunch images:

viewFlow = (ViewFlow) findViewById(R.id.viewflow);
    viewFlow.setAdapter(imgLoader, 5);
    CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
    viewFlow.setFlowIndicator(indic);

1 Answer 1

1

use universal image loader for lazy load just in your getView() method in your adapter.

You don't need to re-invent lazy loading.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. You are right. It seems getView() method works stand alone. I thought changing this method needs changing all imageLoader class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.