jeudi 17 mars 2016

android show custom checkbox in custom table list view

in my android app i have a custom table list view with a hidden checkbox in each row.

at the moment i use this code in my activity to make the checkboxes visible on button press:

x = 1;
while (x < ListView.getChildCount()) {
    CheckBox SelectCheckBox = (CheckBox) ListView.getChildAt(x).findViewById(R.id.SelectCheckBox);
    SelectCheckBox.setChecked(false);

    SelectCheckBox = (CheckBox) ListView.getChildAt(x).findViewById(R.id.SelectCheckBox);
    SelectCheckBox.alpha = 1.0;

    x++;
}

Problem is, that this code shows only the checkboxes of the visible rows. now i found here an solution to change my while ... part to:

for ( int x = 0; x < FoodsListView.getAdapter().getCount(); x++) {

with this code i should select all rows (not only the visible rows) but the next problem is, that my app crash at this point:

CheckBox SelectCheckBox = (CheckBox) ListView.getChildAt(x).findViewById(R.id.SelectCheckBox);

i think i have this line too. but what i have to change? thx :)




Aucun commentaire:

Enregistrer un commentaire