为什么第一种方法还是会复用的呢
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item, null);
viewHolder = new ViewHolder();
viewHolder.checkBox = (CheckBox) convertView.findViewById(R.id.checkBok);
viewHolder.image = (ImageView) convertView.findViewById(R.id.image);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
final CheckBox checkBox = viewHolder.checkBox;
checkBox.setChecked(data.isFlgs());
viewHolder.checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
data.setFlgs(viewHolder.checkBox.isChecked());
}
});
return convertView;
}