I wanted to store checked children names to firebase database. But then, this logic isn't working. I have a constructor with these fields in my Model class.
if (fatherRadioButton.isChecked())
checkincheckout = new CheckInCheckOut(familyName, fatherName, null, checkInTime, checkOutTime, child1, child2, child3);
else
checkincheckout = new CheckInCheckOut(familyName, null, motherName, checkInTime, checkOutTime, child1, child2, child3);
For CheckBoxes, the code is:
public void onCheckboxClicked(View view) {
// Is the view now checked?
boolean checked = ((CheckBox) view).isChecked();
// Check which checkbox was clicked
switch (view.getId()) {
case R.id.checkbox_child1:
if (checked) {
child1 = child1CheckBox.getText().toString();
Log.d(TAG, "Child 1 : " + child1);
}
break;
case R.id.checkbox_child2:
if (checked) {
child2 = child2CheckBox.getText().toString();
Log.d(TAG, "Child 2 : " + child2);
}
break;
case R.id.checkbox_child3:
if (checked) {
child3 = child3CheckBox.getText().toString();
Log.d(TAG, "Child 3 : " + child3);
}
break;
}
}
I'm able to display them on LogCat too. Here is the trace:
05-23 15:39:27.741 26639-26639/D/tag: Radio Button - Mother Name Checked Mary Beth
05-23 15:39:28.116 26639-26639/D/tag: Child 1 : Zoe Johnson
05-23 15:39:28.349 26639-26639/D/tag: Child 2 : Chloe Johnson
05-23 15:39:28.766 26639-26639/D/tag: CheckIn Button Cliked!
Aucun commentaire:
Enregistrer un commentaire