当前位置:首页 > 新闻中心 >

动态viewpager加载图片

作者:永年县聚联紧固件制造有限公司    发布时间:2017-09-02 11:44:45

动态viewpager加载图片

传入网络图片地址就行了

public class MyPagerAdapter extends PagerAdapter { private List viewlist; private Context mContext; public MyPagerAdapter(List 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); } }

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:潜江网站制作 http://qianjiang.666rj.com

  • 上一篇:卡汀财经分享—考证已是折磨,那些非要拿CFAFRM双证的
  • 下一篇:最后一页
  •