Android 将复选框值存储到数组列表

Android 将复选框值存储到数组列表,android,listview,checkbox,Android,Listview,Checkbox,如何将选中复选框的值存储到数组列表中,并在列表中显示它。/…说Checkbox1=“Apple”…到目前为止,我有这个方法 public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { if (checkBox1.isChecked()) { //my problem is below here: I can't seem to add the value of it not the

如何将选中复选框的值存储到数组列表中,并在列表中显示它。/…说Checkbox1=“Apple”…到目前为止,我有这个方法

public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
    if (checkBox1.isChecked()) {
        //my problem is below here: I can't seem to add the value of it not the id and store it in list

        pubsList.add(pub3);
        pub3=Integer.toString(checkBox1.getSelectedItem());
    }
}

希望这能对您有所帮助。

我用它来压缩
add(checkBox4.getText().toString())
 For only one check box e.g.selectAll you can have this---

selectAll.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
         {

           if ( isChecked )
              {
                Log.e(TAG, "Select all Checkbox enabled");
                String ad=(String) selectAll.getText();//get text of selectAll checkbox
                SelectionList.add(ad);//add above text to list of strings

               }
                      if(! isChecked)
                      {
                         //do something if required
                      }

                  }


              });