public class MyAdAdapter extends PagerAdapter {
private List<ImageView> list;
public MyAdAdapter(List<ImageView> list) {
this.list = list;
}
@Override
public int getCount() {
return Integer.MAX_VALUE;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view==object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
position=position%list.size();
ImageView imageView=list.get(position);
container.addView(imageView);
return imageView;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((ImageView)object);
}
private List<ImageView> list;
public MyAdAdapter(List<ImageView> list) {
this.list = list;
}
@Override
public int getCount() {
return Integer.MAX_VALUE;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view==object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
position=position%list.size();
ImageView imageView=list.get(position);
container.addView(imageView);
return imageView;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((ImageView)object);
}
}
/*********************listview截取URL地址***************************/
//赋值
String images = list.get(position).getImages();
//截取url地址
String pic_url = images.split("\\|")[0];
ImageLoader.getInstance().displayImage(pic_url,myViewHolder.getImageView(), MyApp.getOptions());
myViewHolder.getTitle().setText(list.get(position).getTitle());
myViewHolder.getPrice().setText("价格是:"+list.get(position).getPrice());