package wld.bawei.com.myonemoni.view; import android.content.Context; import android.support.v4.view.PagerAdapter; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; import java.util.ArrayList; import java.util.List; import wld.bawei.com.myonemoni.Bean; import wld.bawei.com.myonemoni.Myjiekou; import wld.bawei.com.myonemoni.R; /** * Created by 大金鑫 on 2017/12/2. */ public class Myadapter extends PagerAdapter { private Context context; private List<Bean> arr; private Myjiekou myjiekou; public Myadapter(Context context,List arr,Myjiekou myjiekou){ this.context=context; this.arr=arr; this.myjiekou=myjiekou; } @Override public Object instantiateItem(ViewGroup container, final int position) { ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); ImageLoader.getInstance().displayImage(arr.get(position%arr.size()).getIcon(),imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { myjiekou.Jiekou(position%arr.size()); } }); container.addView(imageView); return imageView; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } @Override public int getCount() { return Integer.MAX_VALUE; } @Override public boolean isViewFromObject(View view, Object object) { return view==object; } }
viewpager
最新推荐文章于 2024-06-25 23:42:12 发布
本文介绍了一种自定义的ViewPager适配器实现方法,该适配器通过继承PagerAdapter并结合图片加载库Universal Image Loader来展示图片轮播效果。文章详细展示了如何创建适配器类、设置点击监听器及图片加载配置。
摘要由CSDN通过智能技术生成