ListView优化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (null == convertView) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_category, parent, false);
viewHolder = new ViewHolder();
viewHolder.title = (ScaleTextView) convertView.findViewById(R.id.text);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.title.setText(getItem(position).getText());
return convertView;
}
private static class ViewHolder {
TextView title;
}