jeudi 31 mars 2016

only first element in checkbox is selected i need select all item on listview

here is my code for check all items on listview. only first element in checkbox is selected i need select all item on listview

public void onCheckedChanged( Compound Button button View, boolean is Checked) {
        Check Box c b=(Check Box)find View By Id(R.id. c b List_hook);
        Text View ex=(Text View) find View By Id(R.id.t v list_name);


        if(is Checked)
        {

            for(integer I =1; I<=l v. get Child Count();I++)
            {
                l v. set Item Checked(I,true);
                test.add(ex . get Text().to String());
            }

        }
        if(!is Checked)
        {
            for(integer I=1;I<=l v. get Child Count();I++)
            {
               l v. set Item Checked(I,false);
                test.remove(ex . get Text(). to String());
            }
        }
    }
}




Aucun commentaire:

Enregistrer un commentaire