0

I have a listview with simple_list_item_multiple_choice adapter and when I check one of checkbox item, this unchecks the others checkboxes, until here well, but I want to change backgroundcolor of the others checkboxes too.

here it is my setadapter:

final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_multiple_choice, android.R.id.text1, values);
        listView.setAdapter(adapter);
        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

1 Answers1

0

ok, I found a solution, here it is to same questions

SparseBooleanArray checked = listView.getCheckedItemPositions();
                int size = checked.size(); // number of name-value pairs in the array
                for (int i = 0; i < size; i++) {
                    int key = checked.keyAt(i);
                    boolean value = checked.get(key);
                    if (value) {
                        row = listView.getChildAt(i);
                        row.setBackgroundColor(Color.parseColor("#33B5E5"));
                    }else{
                        row = listView.getChildAt(i);
                        row.setBackgroundColor(Color.parseColor("#F0F0F0"));
                    }
                }

row is View globlal variable, thank's anyway!!