0
我正在使用帶圓圈指示器的ViewPager來顯示圖片。Android Lazy loading ViewPager
我想使用一些圖片的網址來代替。實際上懶惰加載ViewPager中的一些圖像與圓指標。我必須將默認圖像適配器更改爲lazyloading適配器(它獲取圖像的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);
謝謝。你是對的。看起來'getView()'方法是獨立的。我認爲改變這個方法需要改變所有的imageLoader類。 –