选中复选框后 - 在电子邮件

时间:2017-08-11 09:43:08

标签: android email checkbox

我正在创建一个应用程序,用户将数据输入表单然后点击按钮,打开一个电子邮件应用程序并将其发送到输入的电子邮件地址。

我有3个复选框,一个询问用户是否想要回电,一个是否需要回电子邮件,另一个说不回复。我目前的java代码是:

        public void submitTicket(View view){
    EditText formName = (EditText)findViewById(R.id.etName);
    String name = formName.getText().toString();

    EditText formPhone = (EditText)findViewById(R.id.etPhone);
    String phone = formPhone.getText().toString();

    EditText formAsset = (EditText)findViewById(R.id.etPhone);
    String asset = formAsset.getText().toString();

    EditText formLocation = (EditText)findViewById(R.id.etPhone);
    String location = formLocation.getText().toString();

    EditText formIssue = (EditText)findViewById(R.id.etIssue);
    String issue = formIssue.getText().toString();

    CheckBox phoneCheckBox = (CheckBox)findViewById(R.id.cbPhone);
    boolean phoneBack = phoneCheckBox.isChecked();

    CheckBox emailCheckBox = (CheckBox)findViewById(R.id.cbPhone);
    boolean emailBack = emailCheckBox.isChecked();

    CheckBox noCheckBox = (CheckBox)findViewById(R.id.cbPhone);
    boolean noThanks = noCheckBox.isChecked();

    String ticketMessage = ticketSummary(name, phone, asset, location, issue,
            phoneBack, emailBack, noThanks);

然后调用以上所有方法的方法是:

private String ticketSummary(String name, String phone, String asset, String location, String issue, boolean phoneBack, boolean emailBack, boolean noThanks){
    String ticketMessage = getString(R.string.ticket_request_name, name);
    ticketMessage += "\n";
    ticketMessage += "\n" + getString(R.string.ticket_request_number, phone);
    ticketMessage += "\n";
    ticketMessage += "\n" + getString(R.string.ticket_request_asset, asset);
    ticketMessage += "\n";
    ticketMessage += "\n" + getString(R.string.ticket_request_location, location);
    ticketMessage += "\n";
    ticketMessage += "\n" + getString(R.string.ticket_request_issue, issue);
    ticketMessage += "\n";

在最后一行,我想从复选框中获取数据,例如,如果勾选了回拨框,则应在电子邮件中说明"用户请求回拨"。如果勾选了电话和电子邮件,那么"用户请求电话或电子邮件回复"如果勾选了“无感谢”复选框,那么"当问题解决后,用户不需要更新"。

1 个答案:

答案 0 :(得分:0)

  

当您单击电子邮件提交按钮然后在提交按钮clicklistener中,您编写用于发送电子邮件的代码,该代码由某些INTENT操作执行。并使用意图发送数据