安卓开发之listView优化篇
来源:互联网 发布:c语言程序运行闪退 编辑:程序博客网 时间:2024/06/06 11:36
1.复用ConvertView:
2.ViewHolder重用组件
标准模板写法转自菜鸟教程一位安卓开发者的博客@Overridepublic View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if(convertView == null){ convertView = LayoutInflater.from(mContext).inflate(R.layout.item_list_animal,parent,false); holder = new ViewHolder(); holder.img_icon = (ImageView) convertView.findViewById(R.id.img_icon); holder.txt_aName = (TextView) convertView.findViewById(R.id.txt_aName); holder.txt_aSpeak = (TextView) convertView.findViewById(R.id.txt_aSpeak); convertView.setTag(holder); //将Holder存储到convertView中 }else{ holder = (ViewHolder) convertView.getTag(); } holder.img_icon.setBackgroundResource(mData.get(position).getaIcon()); holder.txt_aName.setText(mData.get(position).getaName()); holder.txt_aSpeak.setText(mData.get(position).getaSpeak()); return convertView;}//内部类static class ViewHolder{ ImageView img_icon; TextView txt_aName; TextView txt_aSpeak;}
阅读全文
0 0
- 安卓开发之listView优化篇
- 安卓开发之ListView优化方案
- 安卓开发之ListView
- [安卓]手机管家(十三)通讯卫士之listview优化
- 安卓之高级控件Listview的优化
- 安卓之高级控件Listview的优化
- 安卓开发之基于ListActivity的LIstView的用法
- 安卓控件之ListView
- 安卓基础之ListView
- 安卓ListView优化(1)
- 安卓ListView的性能优化
- 安卓ListView优化(1)
- 安卓开发,listview的优化,减少内存消耗,复用convertView、ViewHolder和分页加载
- 安卓开发,布局优化之过度绘制
- 【Android】安卓开发实战之使用layout_weight优化布局
- 【安卓-自定义布局】安卓App开发思路 一步一个脚印(十三)关于ListView的优化总结
- 安卓内存优化之工具篇
- 安卓开发性能优化
- Null 合并运算符( ?? )
- 1071. 小赌怡情(15)
- 机器学习算法之决策树
- 计算长方形的面积
- python基础总结练习——打飞机
- 安卓开发之listView优化篇
- 04-树5 Root of AVL Tree(25 分)
- 1072. 开学寄语(20)
- C语言中的选择排序法
- sql常用(一)
- Hive之——操作语句整理
- 时间段预约库存功能的实现
- 正则捕获
- [BZOJ3144][HNOI2013]切糕-网络流