0
顯示文本我創建一個應用程序,從而用戶輸入數據轉換成表格,然後點擊該按鈕,打開一個電子郵件應用程序,並把它發送到放置在電子郵件地址當複選框被選中 - 在電子郵件
我有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";
在最後一行,我想從複選框範例中得到的數據,如果回電框被打勾,在電子郵件中應該說「用戶請求回電」。如果同時打了電話和電子郵件,請選擇「用戶請求打電話或回電子郵件」,如果勾選了「不感謝」複選框,則「用戶在問題解決時不需要更新」。