设置文本在对话框Android中不起作用

时间:2018-11-11 12:35:37

标签: android android-edittext settext

我目前正在一个项目中,当用户单击电子邮件按钮时,它将带他到一个对话框,其中他的电子邮件已插入编辑文本中,但是我面临的问题是{{1} }函数未实现。 这是我的代码:

setText

我已经测试过,看看是否正在解析该变量,即使在尝试Button Emailbtn = (Button) dialog.findViewById(R.id.btnEmail); Emailbtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { v.setSelected(true); final Dialog dialog = new Dialog(ViewQuotesD.this); dialog.getWindow(); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialemail); //Getting content for email final Button btnsend = (Button) dialog.findViewById(R.id.btnEmail); btnsend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final EditText emaill = (EditText) dialog.findViewById(R.id.edtEmail); emaill.setText(SlectedName); String email = emaill.getText().toString().trim(); String subject = "Your Quotations"; String message = "Hi " + SelectedEmail +" "+SelectedSurname+"\n"+ "FABRIC: \n"+ "Total price of fabric = R" + SelectedFabricTotal+ "\n"+ "LINING: \n"+ "Total price of lining = R" + SelectedLiningtotal+ "\n"+ "LABOUR: \n"+ "Total labour cost on fabric = R" + SelectedFabricLabour+ "\n"+ "VOIL: \n"+ "Total price of voil = R" + SelectedVoilTotal +"\n"+ "Labour price on voil = R" + SelectedVoilLabour+ "\n"+ "RAILINGS: \n"+ "Total price of railings = R" + SelectedRailTotal+ "\n"+ "VALANCE: \n"+ "Total price of valance = R" + SelectedValTotal+ "\n"+ "INSTALLATION: \n"+ "Total installation cost = R" + SelectedInstall+ "\n"+ "GRAND TOTAL = R" + SelectedPrice; //Creating SendMail object SendMail sm = new SendMail(ViewQuotesD.this, email, subject, message); //Executing sendmail to send email sm.execute(); finish(); startActivity(getIntent()); Toast.makeText(ViewQuotesD.this , "Email sent" , Toast.LENGTH_LONG).show(); } }); } }); dialog.show(); 这样的普通字符串的情况下,它也并未在SetText上实现显示。

1 个答案:

答案 0 :(得分:0)

如果代码的逻辑正确,请检查布局xml文件,也许EditText的内容已更改,但由于文本颜色与背景颜色相同而无法显示。

尝试更改Edittext的颜色进行测试。