传入网络图片地址就行了
public class MyPagerAdapter extends PagerAdapter {
private List<String> viewlist;
private Context mContext;
public MyPagerAdapter(List<String> viewlist, Context mContext) {
this.viewlist = viewlist;
this.mContext = mContext;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return viewlist.size();
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
// TODO Auto-generated method stub
return arg0 == arg1;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
// TODO Auto-generated method stub
View imagelayout = LayoutInflater.from(mContext).inflate(
R.layout.view1, null);
ImageView imageview = (ImageView) imagelayout
.findViewById(R.id.imageloaderimageview);
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.ic_launcher)
.showImageOnFail(R.drawable.icon15_03_middle)
.showImageForEmptyUri(R.drawable.icon15_03_middle)
.cacheInMemory(true).cacheOnDisc(true)
.bitmapConfig(Bitmap.Config.RGB_565).build();
ImageLoader.getInstance().displayImage(viewlist.get(position),
imageview, options);
((ViewPager) container).addView(imagelayout, 0);
return imagelayout;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// TODO Auto-generated method stub
((ViewPager) container).removeView((View) object);
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/a4384142/article/details/47661897