Checkbox auto call onCheckedChange when listview scroll?

前端 未结 5 947
终归单人心
终归单人心 2020-12-02 14:26

I have a problem with listview which list item contain a checkbox. When i check a box and scroll list, checkbox sometime auto call oncheckedchange and value of checkbox is c

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 15:15

    The OnClickListener is worked for me with the same problem and i can send a data to another activity

    holder.cks.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    final boolean isChecked = holder.cks.isChecked();
                    if (isChecked) {
                        System.out.println(position + "Checked");
                        holder.cks.setChecked(true);
                        positionArray.set(position, true);
                        DATA2="1";
    
    
    
                    } else {
                        System.out.println(position + "unChecked");
                        holder.cks.setChecked(false);
                        positionArray.set(position, false);
    
                        DATA2 = "0";
    
                    }
                    DATA1=String.valueOf(position+1);
    
                    DATA3=map.get(COL5);
                    DATA4=map.get(COL6);
                    DATA5=map.get(COL7);
    
    
    
                    Intent intent = new Intent(activity, updatelicaldata.class);
                    intent.putExtra("message1", DATA1);
                    intent.putExtra("message2", DATA2);
                    intent.putExtra("message3", DATA3);
                    intent.putExtra("message4", DATA4);
                    intent.putExtra("message5", DATA5);
                    System.out.println("ACTIVITY IS START");
    
                    activity.startActivity(intent);
    
                }
                });
    

提交回复
热议问题