lundi 12 décembre 2016

Android checkbox select all not selecting all childs

I am developing an android app, in which there is a custom list view with text view and check box is there. In this listview contact list of mobile will get displayed, now I need to add a select all checkbox and when it is checked all check boxes of conatcts needs to select. I wrote code for that but what happening is when I am selecting checkbox of select all... current view of contacts is getting selcting and the contacts in bottom scrollview is not getting selected. I am giving the code below, please check it and help me to do the changes.

switch(view.getId()) {
              case R.id.chkSelectAll:
                  if (checked)
                  {
                      Toast.makeText(MyList.this, "Checked.", Toast.LENGTH_LONG).show();
                      for(int i=0; i<lv.getChildCount();i++)

                      {
                          CheckBox cb = (CheckBox)lv.getChildAt(i).findViewById(R.id.selected);
                          cb.setChecked(true);
                      }
                  }

                  else
                  {
                      Toast.makeText(MyList.this, "Not Checked.this time", Toast.LENGTH_LONG).show();
                      for(int i=0; i<lv.getChildCount();i++)
                      {
                          CheckBox cb = (CheckBox)lv.getChildAt(i).findViewById(R.id.selected);
                          cb.setChecked(false);
                      }
                  }
                  break;

          }
      }




Aucun commentaire:

Enregistrer un commentaire