BaseAdapter适配器view缓存
2015-11-13 17:10
357 查看
public View getView(int position, View convertView, ViewGroup parent) { final ContentData data = activity.getCommonalityInfo().getRecommendData().getDatas().get(position); HashMap<String, View> tag; if (convertView == null || (tag = (HashMap<String, View>) convertView.getTag()) == null) { convertView = View.inflate(activity, R.layout.dialog_item_video_about, null); tag = new HashMap<String, View>(); tag.put("image", convertView.findViewById(R.id.iv_icon)); tag.put("title", convertView.findViewById(R.id.tv_title)); tag.put("timeLength", convertView.findViewById(R.id.tv_timeLength)); convertView.setTag(tag); } // 防止重复加载item if (parent.getHeight() != 0) { final ImageView image = (ImageView) tag.get("image"); String imgUrl = Public.addParamsToImageUrl(data.getHorizontalPic(), Public.dip2px(activity, 100), Public.dip2px(activity, 75)); image.setTag(imgUrl); Bitmap bitmap = activity.getAsyncImage().loadImage(imgUrl, new ImageCallback() { @Override public void imageLoaded(Bitmap bitmap, String imageUrl) { if (busy) { return; } if (bitmap != null) { if (imageUrl.equals(image.getTag().toString())) image.setImageBitmap(bitmap); } } }); if (bitmap != null) image.setImageBitmap(bitmap); else image.setImageResource(R.drawable.nodata); ((TextView) tag.get("title")).setText(data.getName()); String timeLength = ""; if (null != data.getDuration()) { timeLength = QLStringUtils.generateTime(1000 * Integer.parseInt(data.getDuration()));; } ((TextView) tag.get("timeLength")).setText("时长:" + timeLength); } return convertView; }
相关文章推荐
- Oracle 中count(1) 和count(*) 的区别
- Objective-C 笔记一(HelloWorld)
- Hibernate中Criteria的用法
- JDBC--获取数据库连接
- Advanced Plugin Concepts
- SpringMVC常用注解,返回方式,路径匹配形式,验证
- spring bean setter属性注入
- Debug与Release
- Python 类属性的理解
- Ngui忽略ui界面的物体
- web项目接入cas单点登陆
- 当我们谈开机的时候我们在谈论些什么
- tornado 学习笔记10 Web应用中模板(Template)的工作流程分析
- hibernate一对一外键单向关联
- 【C语言】 实现strncat
- QQ音乐远程控制,旧iPhone连音响当播放器,另一个手机远程控制
- android开发的一些网址
- didReceiveMemoryWarning-内存警告处理方法
- JAVA学习9_@SuppressWarnings注解用法详解
- iOS编程中的内存管理方式