在我的应用程序中,我通过get view方法在列表视图中显示复选框。但是当我单击任何复选框并向下滚动列表时,还有一些复选框同时被检查但我从未检查过他们永远都没有。在这种情况下,我找不到任何东西。求助。
public class viewHolder {
TextView top;
TextView bottom;
TextView below;
TextView idhold;
CheckBox cb;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
viewHolder holder;
if(convertView==null){
LayoutInflater inflator=context.getLayoutInflater();
convertView=inflator.inflate(R.layout.favouritetextviewonly, null);
holder=new viewHolder();
holder.top=(TextView)convertView.findViewById(R.id.topper);
holder.bottom=(TextView)convertView.findViewById(R.id.lower);
holder.below=(TextView)convertView.findViewById(R.id.lowest);
holder.idhold=(TextView)convertView.findViewById(R.id.idholder);
---> holder.cb=(CheckBox)convertView.findViewById(R.id.favouritecheckbox);
convertView.setTag(holder);
}
else{
holder=(viewHolder)convertView.getTag();
}
holder.top.setText(names[position]);
holder.bottom.setText(types[position]);
holder.below.setText(numbers[position]);
holder.idhold.setText(""+keys[position]);
----> holder.cb.setVisibility(View.VISIBLE);
return convertView;
}