0

我有一个安卓应用程序。我在其中有 ListView。列表视图由 ArrayAdapter 和布局文件构成。在布局文件中,我有复选框。所以我想通过按下按钮查看是否所有复选框都被选中。我怎么能做到这些?更新:我想看看哪些复选框被选中

4

1 回答 1

0

You can get the number of checked items in your list with the code:

private int getChecked()
{
    SparseBooleanArray checked = yourList.getCheckedItemPositions();

    return checked.size();
}

Edit: To check that every item is checked:

private boolean isEveryChecked()
{
     SparseBooleanArray checked = yourList.getCheckedItemPositions();

     return checked.size()==yourList.getCount();
}

yourList is a ListView.

于 2013-01-07T14:54:18.657 回答