mardi 16 août 2016

How to apply shared preference to checkbox

I am new to android development I created a checkbox and how to save check/uncheck using share preference

final Button add = (Button) findViewById(R.id.add);
        add.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                addNewBubble();
                add.setEnabled(false);
            }
        });

        CheckBox checkBox = (CheckBox)findViewById(R.id.add_fb);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                isCheckedValue = isChecked;

            }
        });

    }

There are two Check boxes in this code 'add' and 'add_fb' I want to make the app remember if the checkbox are checked or unchecked




Aucun commentaire:

Enregistrer un commentaire