WebCachedImageView icon indicating copy to clipboard operation
WebCachedImageView copied to clipboard

Adding a WebCachedImageView programatically

Open 4gus71n opened this issue 10 years ago • 0 comments

Hi there! I try add a WebCachedImageView programatically in the instantiateItem method of my PageAdapter like this:

@Override public Object instantiateItem(ViewGroup container, int position) { WebCachedImageView imageView = new WebCachedImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setImageUrl(images.get(position).getUrl()); ((ViewPager) container).addView(imageView, 0); return imageView; }

I tried in several ways with several ScaleType's but the result was the same, show only a color, or nothing. Then I changed the method to this:

@Override public Object instantiateItem(ViewGroup container, int position) { WebCachedImageView imageView = (WebCachedImageView) inflater.inflate(R.layout.item_viewpager_page, null); imageView.setImageUrl(images.get(position).getUrl()); ((ViewPager) container).addView(imageView, 0); return imageView; }

And now It's working, but isn't too nice given that I have to inflate a new View in each instantiateItem call. Maybe I'm using wrong the library?. Thanks, your library rulez :dancers:

4gus71n avatar Oct 07 '13 12:10 4gus71n