我正在使用Picasso从服务器获取图像并在viewpager中显示,但是我得到一些奇怪的错误,我的一些图像没有显示,当我静态加载图像时它们正在显示但是当从服务器加载图像时他们消失了,尤其是在3岁之后.
这是我的ViewPagerAdapter.java:
public Object instantiateItem(final ViewGroup container,int position) { layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View itemView = layoutInflater.inflate(R.layout.viewpager_item,container,false); /** * Loading the image view */ // Locate the ImageView in viewpager_item.xml ImageView sliderItem = (ImageView) itemView.findViewById(R.id.viewpagerImageView1); // Capture position and set to the ImageView /* if(requestCreatorListIterator.hasNext()) { requestCreatorListIterator.next().into(sliderItem); }*/ slider[position].into(sliderItem); //sliderItem.setImageResource(slider[position]); // Add viewpager_item.xml to ViewPager ((ViewPager) container).addView(itemView); //https://stackoverflow.com/questions/21368693/how-to-do-circular-scrolling-on-viewpager ((ViewPager) container).addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels) { } @Override public void onPageSelected(int position) { // skip fake page (first),go to last page if (position == 0) { ((ViewPager) container).setCurrentItem(slider.length - 2); } // skip fake page (last),go to first page if (position == slider.length - 1) { ((ViewPager) container).setCurrentItem(1); //notice how this jumps to position 1,and not position 0. Position 0 is the fake page! } } @Override public void onPageScrollStateChanged(int state) { } }); }