Skip to content Skip to sidebar Skip to footer

Android Listview Of Checkboxes Always Checks First Item If Any Item Is Checked

Recently, I encountered a problem with a ListView. In it there is a list of checkboxes. The checked items are fed to the calling Activity that starts my ListActivity with startActi

Solution 1:

You need to be aware that the checkbox from a convert view might be checked. You need to uncheck it if the text is not in the list.

private void fillText(View v, int id, String text) {
        Log.i(LOG_TAG, "this is fillText, our text is: " + text);

        CheckBox checkBox = (CheckBox) v.findViewById(id);
        if ( checkedItems.contains(text)) {
            Log.i(LOG_TAG, "item has to be checked");
            checkBox.setChecked(true);
        } else {
            checkBox.setChecked(false);     
        }

Post a Comment for "Android Listview Of Checkboxes Always Checks First Item If Any Item Is Checked"