Android - Unable to check all the CheckBoxes in a custom listview because of recycling issue?

前端 未结 2 1590
醉梦人生
醉梦人生 2021-01-22 12:36

I have a custom listview adapter with a imageview, textview and a checkbox. and i also have a button and a checkbox in my main layout(not in listview).

What here i want

2条回答
  •  太阳男子
    2021-01-22 13:03

    This morning I read an answer of an issue like this, and they recommend we put holder.checkBox.setChecked(itemChecked.get(position)); before holder.checkBox.setOnCheckedChangeListener

    So, getView function will be rewritten like this:

    public View getView(....)
    {
        ...
        holder.checkBox.setChecked(itemChecked.get(position));///move to here
        holder.checkBox.setOnCheckedChangeListener(...);
        ...
    )
    

提交回复
热议问题