gpt4 book ai didi

java - Imageloader 几张图像到 ViewPager

转载 作者:行者123 更新时间:2023-12-02 08:51:28 25 4
gpt4 key购买 nike

以下是使用 volley 将图像从数据库检索到 View 页面的代码的一部分。我怎样才能将七张图片加载到 ImageView (加载所有图像位置)。如果我在“加载所有图像”位置独立输入任何图片,例如图片2或图片3,它会正确加载。

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 只需添加图片的字符串数组并将其设置在 ImageView 中,如下所示。图片变量下方

String [] urls = new String[] {图片,图片2,........}

然后在图像加载器中加载imageLoader.get(urls,ImageLoader.getImageListener(imageView,
R.drawable.placeholder, R.drawable.error));

关于java - Imageloader 几张图像到 ViewPager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60740643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com