I refactored my code, moving from an Activity (containing checkboxes) to Fragment. It used to work as demanded (two-state checkbox) in the Activity but now for some reason the checkbox is a tri-state checkbox.
Fragment:
This doesn't work (tri-state):
chkMonday.setChecked(settings.getBoolean(getString(R.string.chkSettingsMondayKey), true));
The checkbox has a tri-state and I can't figure out why:
- default state when Fragment is loaded: empty with highlighted borders.
- one click: unchecked (gray)
- one click: checked (check mark + highlighted border)
Discovered that this works (two-state):
boolean monday = settings.getBoolean(getString(R.string.chkSettingsMondayKey), true);
chkMonday.setChecked(monday);
Do you have any explanation? Thank you!
Aucun commentaire:
Enregistrer un commentaire