mercredi 29 avril 2015

Select CheckBox of all ListViewItem

I got a ListActivity with list items I've created. Each item got a CheckBox in it. In addition, the layout got a button which is suppose to simply check all the check boxes, yet it's not working even though the OnClickListener of the button is being called.

This is the button's OnClickListener:

private OnClickListener selectAllButtonOnClickListener = new View.OnClickListener()
{
    View listItem;
    CheckBox cb;

    @Override
    public void onClick(View v)
    {
        int itemCount = myList.getCount();
        for (int i = 0; i < itemCount; i++)
        {
            listItem = myList.getAdapter().getView(i, null, null);
            cb = (CheckBox) listItem.findViewById(R.id.the_checkBox);
            cb.setChecked(true);
        }

    }

};

Is there something wrong with how I'm trying to check all the checkboxes?




Aucun commentaire:

Enregistrer un commentaire