I'm trying to recieve checkbox choices inside my Fragment class, however I'm not able to use the way I've used in Activities (calling android:onClick="onCheckboxClicked"
method from a layout.xml
), because I get the "method onCheckboxClicked not found" everytime this method is called.
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_wifi):
if (checked) {
editor.putBoolean("wifi_on_off", true);
}
else {
editor.putBoolean("wifi_on_off", false);
}
break;
}
editor.apply();
}
So, I've implemented the View.OnClickListener, but this doesn't get any checkbox checks/unchecks:
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.checkBox_wifi:
boolean checked = ((CheckBox) view).isChecked();
if (checked) {
editor.putBoolean("wifi_on_off", true);
} else {
editor.putBoolean("wifi_on_off", false);
}
editor.apply();
break;
}
}