everyone! I want to implement app that:
In my code when I try to implement it the second checkbox is also checked and disabled despite the fact that I haven't clicked it.
Please help! See my code below:
public void CheckboxCare(@NonNull View v){
switch (v.getId()){
case R.id.checkbox_p2106:
if(pref.contains("checked") && pref.getBoolean("checked", false) == true){
setChecked(P2106);
disableCheckbox(P2106);
}else{
setNotChecked(P2106);
}
checkboxListener(P2106);
break;
case R.id.checkbox_mp2106:
if(pref.contains("checked") && pref.getBoolean("checked", false) == true){
setChecked(MP2106);
disableCheckbox(MP2106);
}else{
setNotChecked(MP2106);
}
checkboxListener(MP2106);
break;
}
}
Create object for each check box send on that function call based on your requirement
public void CheckboxCare(@NonNull View v){
switch (v.getId()){
case R.id.checkbox_p2106:
{
// write code here
}
case R.id.checkbox_mp2106:
if(pref.contains("checked") && pref.getBoolean("checked", false) == true){
setChecked(checkbox_p2106);// enable one
disableCheckbox(checkbox_p2106);// disable second
}else{
setNotChecked((CheckBox) v);
}
checkboxListener((CheckBox) v);
break;
}
}