设置文本在对话框中不起作用 android
Set Text not working in dialogue box android
我目前正在做一个项目,当用户点击一个电子邮件按钮时,他会进入一个对话框,他的电子邮件已经插入到编辑文本中,但我面临的问题是 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
上实现,即使我尝试了一个普通的字符串,例如 Emaill.setText("test");
它仍然没有'显示。
如果代码逻辑正确,请检查排版xml文件,可能EditText
的内容已经改了,但是因为文字颜色相同所以不显示背景颜色。
尝试更改 Edittext
颜色进行测试。
我目前正在做一个项目,当用户点击一个电子邮件按钮时,他会进入一个对话框,他的电子邮件已经插入到编辑文本中,但我面临的问题是 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
上实现,即使我尝试了一个普通的字符串,例如 Emaill.setText("test");
它仍然没有'显示。
如果代码逻辑正确,请检查排版xml文件,可能EditText
的内容已经改了,但是因为文字颜色相同所以不显示背景颜色。
尝试更改 Edittext
颜色进行测试。