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

Course Queries Syllabus Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 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.