ListView优化三原则

转自:http://www.cnblogs.com/xiongbo/archive/2011/07/14/2106387.html

1.复用convertView

在getItemView中,判断convertView是否为空,如果不为空,可复用。

2.异步加载图片

item中如果包含有webimage,那么最好异步加载

3.快速滑动时不显示图片

当快速滑动列表时(SCROLL_STATE_FLING),item中的图片或获取需要消耗资源的view,可以不显示出来;而处于其他两种状态(SCROLL_STATE_IDLE 和SCROLL_STATE_TOUCH_SCROLL),则将那些view显示出来


SCROLL_STATE_FLING The user had previously been scrolling using touch and had performed a fling.
SCROLL_STATE_IDLE The view is not scrolling.
SCROLL_STATE_TOUCH_SCROLL The user is scrolling using touch, and their finger is still on the screen

SCROLL_STATE_FLING是手指离开屏幕,view由于惯性在快速滚动的状态

你可能感兴趣的:(ListView优化三原则)