我正在使用带有圆圈指示符的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);