public class ViewPagerAdapter extends PagerAdapter { private ArrayList<GroupAlbumPhotoBean> image_list; private LayoutInflater inflater; private ViewPagerItemClickListener callback; public GroupViewPagerAdapter(Context context, ArrayList<GroupAlbumPhotoBean> image_list, ViewPagerItemClickListener callback) { this.image_list = image_list; inflater = LayoutInflater.from(context); this.callback = callback; } @Override public int getCount() { if (image_list != null && image_list.size() > 0) { return image_list.size(); } else { return 0; } } @Override public boolean isViewFromObject(View arg0, Object arg1) { return arg0 == arg1; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } @Override public Object instantiateItem(ViewGroup container, final int position) { View itemview = inflater.inflate(R.layout.activity_show_big_pic_item, null); PhotoView imageView = (PhotoView) itemview .findViewById(R.id.iv_show_big_pic); ImageUtils.setImage(image_list.get(position).getUrl(), imageView); imageView.setOnPhotoTapListener(new OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { callback.onItemClick(position); } }); ((ViewPager) container).addView(itemview, 0); return itemview; } @Override public int getItemPosition(Object object) { return POSITION_NONE; } }
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦