dimanche 20 mars 2016

android checkbox and check change listener

in my android app i have a custom table list with one checkbox for each row.

i would like to check, if a checkbox was checked or unchecked. for this i have this code:

SelectCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (SelectCheckBox.isChecked()) {
                            Log.e("-->", "IS CHECKED");
                        } else {
                            Log.e("-->", "IS NOT CHECKED");
                        }
                    }
                });

this works fine, if i check/uncheck the checkboxes. but i have got another code, which checks all checkboxes at once, after pressing a button.

SelectCheckBox.setChecked(true);

but than the CheckedChangeListener will not be active.




Aucun commentaire:

Enregistrer un commentaire