ViewPager + Picasso String array doesn't work
- Dominant language
- Java
- Stars
- 18.8k
- Forks
- 3.9k
- PR merge metrics
- No merged PRs in 30d
Description
Please help me. I'm following the example ViewPagerActivity from sample PhotoView and I want to change the drawables with Picasso url images. So, I'm trying to put multiple images in HackyViewPager via Picasso String array of URL's.
I have a String array of URL's obtained from one single String **stringDefinitionGemstonesPhoto**
`String[] strAry = stringDefinitionGemstonesPhoto.split(",");`
and the final code in SamplePageAdapter is:
```
static class SamplePagerAdapter extends PagerAdapter {
private static final int[] sDrawables = {R.drawable.wallpaper, R.drawable.wallpaper, R.drawable.wallpaper,
R.drawable.wallpaper, R.drawable.wallpaper, R.drawable.wallpaper};
@Override
public int getCount() {
return sDrawables.length;
}
@Override
public View instantiateItem(ViewGroup container, int position) {
PhotoView photoView = new PhotoView(container.getContext());
String[] strAry = stringDefinitionGemstonesPhoto.split(",");
for (final String str : strAry) {
System.out.println(str);
Picasso.get().load(str).into(photoView, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
}
});
}
//photoView.setImageResource(sDrawables[position]);
// Now just add PhotoView to ViewPager and return it
container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return photoView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
}
```
Whit one link is working, but with more than two, the HackyViewPager appear blank (white). In Log it appears that the links are splitted correctly.
What is wrong?
Contributor guide
Assessment
This issue has not been assessed yet.