Android mobile guard-business logic of navigation interface 4, android guard
This article implements the business logic of navigation interface 4. The navigation interface 4 is as follows:
For more information, see http://www.cnblogs.com/wuyudong/p/5952640.html.
The Code is as follows:
Private void initUI () {cb_box = (CheckBox) findViewById (R. id. cb_box); // 1, whether to display boolean open_security = SpUtil in the selected status. getBoolean (this, ConstantValue. OPEN_SECURITY, false); cb_box.setChecked (open_security); // 2. Based on the status, modify if (open_security) {cb_box.setText ("enabled Security Settings") in the subsequent text of the checkbox ");} else {cb_box.setText ("Security Settings disabled");} // 3. When you click this button, the selected state of the listener changes. cb_box.setOnCheckedChangeListener (new CompoundButton. onCheckedChangeListener () {@ Override public void onCheckedChanged (CompoundButton compoundButton, boolean B) {// 4. The status after isChecked is clicked. putBoolean (getApplicationContext (), ConstantValue. OPEN_SECURITY, B); // 5. Modify the displayed text if (B) {cb_box.setText ("Security Settings enabled") based on the enabled/disabled status ");} else {cb_box.setText ("Security Settings disabled") ;}}}); // 4. Status After isChecked is clicked, storing the status after clicking SpUtil. putBoolean (this, ConstantValue. OPEN_SECURITY, cb_box.isChecked ());}
Add logic to the next page. When the checkbox is not selected, click the button to bring up a reminder. The Code is as follows:
Public void nextPage (View view) {boolean open_security = SpUtil. getBoolean (this, ConstantValue. OPEN_SECURITY, false); if (open_security) {Intent intent = new Intent (getApplicationContext (), SetupOverActivity. class); startActivity (intent); finish (); SpUtil. putBoolean (this, ConstantValue. SETUP_OVER, true);} else {ToastUtil. show (this, "anti-theft protection must be enabled ");}}