ViewHolder优化2>:
Posted 孔筱艾Studio
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ViewHolder优化2>:相关的知识,希望对你有一定的参考价值。
ViewHoder优化:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = View.inflate(getActivity(), R.layout.lv_item,
null);
viewHolder = new ViewHolder();
convertView.setTag(viewHolder);
viewHolder.lv_imageView = (ImageView) convertView
.findViewById(R.id.lv_imageView);
viewHolder.lv_textView = (TextView) convertView
.findViewById(R.id.lv_textView);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.lv_textView.setText(list.get(position).title);
class ViewHolder {
ImageView lv_imageView;
TextView lv_textView;
}
以上是关于ViewHolder优化2>:的主要内容,如果未能解决你的问题,请参考以下文章
ListView性能优化——convertView&viewHolder