I am creating a app whereby the user inputs data into a form and then hits the button, opens up a emailing app and sends it off to the email address put in.
I have 3 checkboxes, one that asks if the user wants a call back, one if they want an email back and one saying no thanks to both. My current java code is:
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);
And then the method which calls all the above is:
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";
On the last line, I want to get the data from the checkbox for example, if the call back box was ticked, in the email it should say "The user requests a call back". If both call and email are ticked then "The user requests a call or email back" and if the no thanks checkbox is ticked then "The user doesn't require an update when issue is resolved".
Aucun commentaire:
Enregistrer un commentaire