how to open some more checkbox on click of a specific checkbox and saved its value in shared preferences

Course Queries Syllabus Queries 3 years ago

7.38K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago

 


my app contains 6 check boxes clicking a specific checkbox activates other 3 for ex let the checkbox name human tree animal onclicking tree 3 new chkbox open named mango apple neem also i want save these value in shared prefernces so that when i open app it should retain the value saved here is the what i have tried *all the things are in a custom dialog box

 final Dialog dialog = new Dialog(MainActivity.this);
                            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                            dialog.setContentView(R.layout.menu);
                            Button dialogButton = (Button) dialog.findViewById(R.id.btncross);

                            // if button is clicked, close the custom dialog
                            dialogButton.setOnClickListener(new OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    dialog.dismiss();
                                }
                            });

                             dialog.show();

 cb1 = (CheckBox)dialog.findViewById(R.id.checkBoxHR);
                         cb1.setOnCheckedChangeListener(listener1);

                         cb2 = (CheckBox)dialog.findViewById(R.id.checkBoxDay);
                         cb2.setOnCheckedChangeListener(listener2);

                         cb3 = (CheckBox)dialog.findViewById(R.id.checkBox1);
                         cb3.setOnCheckedChangeListener(listener3);

                        cb10 = (CheckBox)dialog.findViewById(R.id.checkBox10);
                        cb10.setOnCheckedChangeListener(listener10);

                        cb5 = (CheckBox)dialog.findViewById(R.id.checkBox5);
                        cb5.setOnCheckedChangeListener(listener5);

                        cb8 = (CheckBox)dialog.findViewById(R.id.checkBox8);
                        cb8.setOnCheckedChangeListener(listener8);

preferences = getSharedPreferences("syllabus", 0);
                         cb1.setChecked(preferences.
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum