mardi 30 juin 2020

How to keep checkbox checked in one fragment when we move to another fragment and come back

I have an checkbox which gives me a dialog box when checked. I need my checkbox to be checked when i click OK in my dialog box and when i go back to another fragment and come back to the fragment where my checkbox is present.

this is my block of code:

else if(SettingKeyConstants.BACK_UP.equals(key)) {
            Boolean value = backup.isChecked();
            Qlog.d(TAG, "onPreferenceChange() Prefvalue:"+value);
            if(value) {
                SettingsAPI.setBooleanValue(SettingKeyConstants.BACK_UP, false);
            }else {
                DialogEventHandler warningDialogEventHandler = new BaseDialogEventHandler() {
                    @Override
                    public void onOkButtonPressed() {
                        super.onOkButtonPressed();
                        backup.setEnabled(true);
                        SettingsAPI.setBooleanValue(SettingKeyConstants.BACK_UP, true);
                        //backup.setChecked(true);
                        //TODO................
                    }
                    @Override
                    public void onCancelButtonPressed() {
                        super.onCancelButtonPressed();
                        backup.setEnabled(true);
                        backup.setChecked(false);
                    }
                };
                T3DialogManager.showWarningDialog(getString(R.string.back_up_title), getString(R.string.back_up_message), warningDialogEventHandler);
            }
            return true;
        }



Aucun commentaire:

Enregistrer un commentaire