我正在使用带有圆形指示器的ViewPager来显示图片。
我想改用一些图片的网址。实际上,在 ViewPager 中使用圆形指示器延迟加载一些图像。我必须将默认图像适配器更改为延迟加载适配器(获取图像的 url)。请帮我解决一下这个。
图像适配器的代码是这样的:
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;
}
}
主要活动使用此代码来午餐图像:
viewFlow = (ViewFlow) findViewById(R.id.viewflow);
viewFlow.setAdapter(imgLoader, 5);
CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
viewFlow.setFlowIndicator(indic);