解决viewpager中两个item循环左右滑动出现崩溃问题
2016-05-25 18:28
435 查看
在 instantiateItem()方法中 添加如下代码
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view1=LayoutInflater.from(context).inflate(R.layout.photo_view, null);
PhotoView view =(PhotoView) view1.findViewById(R.id.image);
// PhotoView view = new PhotoView(context);
view.enable();
Bitmap bitmap=ImageLoaderUtils.ImageLoader(context, url.get(position), view);
LogUtils.i("---"+bitmap);
// view.setImageResource(imgsId[position]);
//设置为被选择的图片
// mPager.setCurrentItem(pos);
ViewGroup parent = (ViewGroup) view.getParent();
//viewpger 两个页面循环滑动会出现崩溃问题 下面是解决方案
if (parent != null) {
parent.removeAllViews();
}
container.addView(view);
return view;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view1=LayoutInflater.from(context).inflate(R.layout.photo_view, null);
PhotoView view =(PhotoView) view1.findViewById(R.id.image);
// PhotoView view = new PhotoView(context);
view.enable();
Bitmap bitmap=ImageLoaderUtils.ImageLoader(context, url.get(position), view);
LogUtils.i("---"+bitmap);
// view.setImageResource(imgsId[position]);
//设置为被选择的图片
// mPager.setCurrentItem(pos);
ViewGroup parent = (ViewGroup) view.getParent();
//viewpger 两个页面循环滑动会出现崩溃问题 下面是解决方案
if (parent != null) {
parent.removeAllViews();
}
container.addView(view);
return view;
}
相关文章推荐
- VI设计通过企业文化传播企业VI设计视觉感受
- CentOS-6上安装二进制Mariadb
- 【REACT NATIVE 系列教程之七】统一ANDROID与IOS两个平台的程序入口&&区分平台的组件简介...
- 【REACT NATIVE 系列教程之七】统一ANDROID与IOS两个平台的程序入口&&区分平台的组件简介
- P-N学习
- 解决导入其他项目时文件乱码
- iOS中assign,copy,retain之间的区别以及weak和strong的区别,NSString什么时候用copy,什么时候用strong
- [RxJS] Filtering operators: skipWhile and skipUntil
- Linux命令
- Linux定时任务crontab执行脚本出错
- navicat内的主键和外键
- 【python练习】截取网页里最新的新闻
- Leetcode 之Count and Say(35)
- linux 系统监控、诊断工具之 IO wait
- Session的工作机制详解和安全性问题(PHP实例讲解)
- springMVC 接收阿里回调接口
- C++上机作业6
- Mantis 1.2.19 on Windows Server 2012 r2 datacenter 安装及配置随笔
- python 装饰器和 functools 模块
- Java 中字符串的格式化