多个复选框的操作包括在我单击退出按钮时不要再问我一次

时间:2018-04-16 11:09:03

标签: android checkbox dialog

[这里从对话框我保留3个复选框,一个用户可以根据需要选择一个或多个。例如,如果一个人选择了清晰的历史而不再问我,而不是当我点击是按钮它清理所有历史和它永远不会在未来看到对话框。我的问题是它只选择一个就可以正常工作但是当选择更多那个时它只能得到第一个.`

@Override
    public void closeBrowserFromRightMenu() {

        createExitDialog();
    }

    public void createExitDialog() {
        dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setCancelable(true);
        //View view = LayoutInflater.from(this).inflate(this, R.layout.alert_layout, null);
        View view = View.inflate(this, R.layout.alart_exit_dialog, null);
        CheckBox dontShowAgain = view.findViewById(R.id.select_3);
        CheckBox clearHistory = view.findViewById(R.id.select_1);
        CheckBox clearCookies = view.findViewById(R.id.cat_select_2);
        //noinspection Convert2Lambda
        view.findViewById(R.id.ritsDialogCancle).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {


                dialog.dismiss();
            }
        });
        TextView title = view.findViewById(R.id.ritsDialogTitle);
        title.setText(getResources().getString(R.string.exit_message));
        // TextView message = view.findViewById(R.id.ritsDialogMessage);
        //message.setVisibility(View.GONE);
        Button confirm = view.findViewById(R.id.ritsDialogAgree);
        //noinspection Convert2Lambda
        confirm.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                String checkBoxResult = "NOT checked";
                if (clearCookies.isChecked()) {
                    Log.e("hgguygujgjjyfg", "clear cookies");
                    WebUtils.clearCookies(BrowserActivity.this);
                    //mMessageHandler.sendEmptyMessage(2);
                }
                if (clearHistory.isChecked()) {
                    Log.e("hgguygujgjjyfg", "clear history");
                    WebUtils.clearHistory(BrowserActivity.this, mHistoryDatabase);
                    //mMessageHandler.sendEmptyMessage(1);
                }


                if (dontShowAgain.isChecked()) {
                    checkBoxResult = "checked";
                    SharedPreferences settings = getSharedPreferences(SETTINGS_ASK_ME, 0);
                    SharedPreferences.Editor editor = settings.edit();
                    editor.putString("skipMessage", checkBoxResult);
                    // Commit the edits!
                    editor.apply();
                }





                dialog.dismiss();
                ExitActiivity.exitApplication(BrowserActivity.this);
            }
        });


        SharedPreferences settings = getSharedPreferences(SETTINGS_ASK_ME, 0);
        String skipMessage = settings.getString("skipMessage", "NOT checked");
        if (!skipMessage.equals("checked")) {
            dialog.setContentView(view);
            dialog.show();

        } else {
            ExitActiivity.exitApplication(BrowserActivity.this);

        }


    }

] Here is Image Description

0 个答案:

没有答案