listview with checkbox

后端 未结 3 1433
小蘑菇
小蘑菇 2021-01-24 13:42

i want to show a listview with check box like

          checkbox listitem1
          checkbox listitem2
          checkbox listitem3
                  .
                 


        
3条回答
  •  没有蜡笔的小新
    2021-01-24 14:00

    I have the same problem. i have just fixed it 2 days before:

    In the : public View getView

     cb =(CheckBox)row.findViewById(R.id.CheckBox01);
              cb.setChecked(etat[position]);
    
              final int xt=position;
    
              cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                    if(arg0.isChecked())
                    {           
                        etat[xt]=true;
                        //Update the state of Checkbox to the: "tabEtat"
                        Etat.getInstance().setAddIdEtat(String.valueOf(xt));
                            }                         
                    }
                    else
                    {
                        //Update the state of Checkbox to the : "tabEtat"
                        Etat.getInstance().setDeleteIdEtat(String.valueOf(xt));
                            }                          
                    }
                }
            });       
    

提交回复
热议问题