Imageloader 多张图片到 ViewPager
Imageloader Several Images To ViewPager
以下是使用 volley 将图像从数据库检索到 viewpager 的部分代码。如何将七张图片加载到图像视图(加载所有图像 位置)。
如果我在 LOAD ALL IMAGES 位置独立键入任何图片,例如 picture2 或 picture3,它正在正确加载。
public class ViewPagerAdapter extends PagerAdapter {
////////
@Override
public Object instantiateItem(ViewGroup container, final int position) {
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.custom_layout, null);
SliderUtils utils = sliderImg.get(position);
String picture = utils.getSliderImageUrl();
String picture2 = utils.getSliderImage2Url();
String picture3 = utils.getSliderImage3Url();
String picture4 = utils.getSliderImage4Url();
String picture5 = utils.getSliderImage5Url();
String picture6 = utils.getSliderImage6Url();
String picture7 = utils.getSliderImage7Url();
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();
imageLoader.get(**LOAD ALL IMAGES**,ImageLoader.getImageListener(imageView,
R.drawable.placeholder, R.drawable.error));
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
/////
}
});
ViewPager vp = (ViewPager) container;
vp.addView(view, 0);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
ViewPager vp = (ViewPager) container;
View view = (View) object;
vp.removeView(view);
}
}
@NyP 只需添加您的图片的字符串数组并将其设置在图像视图中,如下所示。图片下方vars
String [] urls = new String[] {picture, picture2, ........}
然后加载图片加载器imageLoader.get(urls,ImageLoader.getImageListener(imageView,
R.drawable.placeholder, R.drawable.error));
以下是使用 volley 将图像从数据库检索到 viewpager 的部分代码。如何将七张图片加载到图像视图(加载所有图像 位置)。 如果我在 LOAD ALL IMAGES 位置独立键入任何图片,例如 picture2 或 picture3,它正在正确加载。
public class ViewPagerAdapter extends PagerAdapter {
////////
@Override
public Object instantiateItem(ViewGroup container, final int position) {
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.custom_layout, null);
SliderUtils utils = sliderImg.get(position);
String picture = utils.getSliderImageUrl();
String picture2 = utils.getSliderImage2Url();
String picture3 = utils.getSliderImage3Url();
String picture4 = utils.getSliderImage4Url();
String picture5 = utils.getSliderImage5Url();
String picture6 = utils.getSliderImage6Url();
String picture7 = utils.getSliderImage7Url();
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();
imageLoader.get(**LOAD ALL IMAGES**,ImageLoader.getImageListener(imageView,
R.drawable.placeholder, R.drawable.error));
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
/////
}
});
ViewPager vp = (ViewPager) container;
vp.addView(view, 0);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
ViewPager vp = (ViewPager) container;
View view = (View) object;
vp.removeView(view);
}
}
@NyP 只需添加您的图片的字符串数组并将其设置在图像视图中,如下所示。图片下方vars
String [] urls = new String[] {picture, picture2, ........}
然后加载图片加载器imageLoader.get(urls,ImageLoader.getImageListener(imageView,
R.drawable.placeholder, R.drawable.error));