我的问题是我有一个带有复选框可见性的列表视图,当清除按钮被选中时复选框变得可见我正在查看复选框的状态,但问题是当复选框被选中时,它调用 onCheckChange() 并执行设置状态的工作,但是当我的视图再次将它重新设置为商店状态并再次调用我的 onCheckChanged,我不知道为什么当我向上滚动时它不会恢复我的检查状态......这是我的代码
public View getView(int position,View convertView,ViewGroup parent)
{
final int currentPosition=position;
View row=convertView;
if(row==null)
{
LayoutInflater inflater=((Activity)context).getLayoutInflater();
row=inflater.inflate(layoutResourceId, parent,false);
holder=new Feedbacks();
holder.lvGuestName=(TextView)row.findViewById(R.id.guestName);
holder.checkBox=(CheckBox)row.findViewById(R.id.clearCheck);
row.setTag(holder);
}
else
{
holder=(Feedbacks)row.getTag();
}
if(showCheckbox)
{
holder.checkBox.setVisibility(View.VISIBLE);
}
else
{
holder.checkBox.setVisibility(View.GONE);
}
holder.lvGuestName.setText(feedbackList.get(position).getGuestName());
holder.checkBox.setChecked(checks.get(position));
holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if(isChecked)
{
checks.put(currentPosition, true);
}
else
{
checks.put(currentPosition, false);
}
}
});
return row;
}