Android 手机卫士--导航界面4的业务逻辑

本文实现导航界面4的业务逻辑,导航界面4的界面如下:

本文地址:http://www.cnblogs.com/wuyudong/p/5952640.html,转载请注明出处。

相应的代码如下:

    private void initUI() {
        cb_box = (CheckBox)findViewById(R.id.cb_box);
        //1,是否选中状态的回显
        boolean open_security = SpUtil.getBoolean(this, ConstantValue.OPEN_SECURITY, false);
        cb_box.setChecked(open_security);
        //2,根据状态,修改checkbox后续的文字显示
        if(open_security) {
            cb_box.setText("安全设置已开启");
        } else {
            cb_box.setText("安全设置已关闭");
        }
        //3,点击过程中,监听选中状态发生改变过程,
        cb_box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                //4,isChecked点击后的状态,存储点击后状态
                SpUtil.putBoolean(getApplicationContext(), ConstantValue.OPEN_SECURITY, b);
                //5,根据开启关闭状态,去修改显示的文字
                if(b) {
                    cb_box.setText("安全设置已开启");
                } else {
                    cb_box.setText("安全设置已关闭");
                }
            }
        });
        //4,isChecked点击后的状态,存储点击后状态
        SpUtil.putBoolean(this, ConstantValue.OPEN_SECURITY, cb_box.isChecked());
    }

给”下一页“按钮添加逻辑,当没有选中checkbox的时候,点击按钮后弹出提醒,代码如下:

    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, "必须开启防盗保护");
        }
    }

 

posted @ 2016-10-12 19:44  wuyudong  阅读(492)  评论(0编辑  收藏  举报
Top_arrow