从哪几个方面优化入手?
1. 复用view (convertView))。
View getView(int position, View convertView, ViewGroup parent);
convertView 即为复用的view,不为null时既可复用。
2. 使用 ViewHolder。
解决 findViewById() 重复调用带来的性能问题。通过view.setTag() 设置在view中,通过view.getTag()取出。
3. 图片(Bitmap的优化)。
图片的缓存(时间上)。图片的裁剪(内存上)。
4. 分批加载数据。
如过数据过多(比如超过1万条),不能全部存储,可以分页存储,每个时刻只存储100条。(这100条也是分批从服务器请求的)
5. 滑动过程中不加载图片
addOnScrollListener(): onScrollStateChanged(), onScroll()