@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
if(convertView==null){
holder=new ViewHolder();
convertView=View.inflate(context, R.layout.item, null);
holder.title=(TextView) convertView.findViewById(R.id.item_text);
holder.checkBox=(CheckBox) convertView.findViewById(R.id.item_checkbox);
convertView.setTag(holder);
}else{
holder=(ViewHolder) convertView.getTag();
}
final CheckBox cb=holder.checkBox;
cb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(cb.isChecked()){
cb.setChecked(true);
list.get(position).sf=true;
}else{
list.get(position).sf=false;
cb.setChecked(false);
}
}
});
holder.title.setText(list.get(position).title);
cb.setChecked(list.get(position).sf);
return convertView;
}
class ViewHolder{
TextView title;
CheckBox checkBox;
}
</php>