【发布时间】:2017-11-25 05:04:14
【问题描述】:
我正在尝试创建一个dialog 框,带有标题、正文(消息)、ok -option。
我如何将它们逐行分隔(我的意思是按行分为三部分)?
这是我正在使用的代码:
public void dialog_vhe(View view){
String button_details;
button_details = ((Button) view).getText().toString();
AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
builder2.setMessage(" You can use either your garnt number or TRN.\n" +
" The Visa Grant Number can be found on your visa grant notification.\n " +
" The Transaction Reference Number can be found in your ImmiAccount and on any correspondence from the department. ")
.setCancelable(false)
.setNegativeButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert2 = builder2.create();
alert2.setTitle("REFERENCE NUMBER");
alert2.show();
setContentView(R.layout.activity_visa_holder_enquiry);
}
【问题讨论】:
-
您是否使用了自定义警报对话框?
-
创建自定义布局并在活动中充气
-
在String.xml中创建一个字符串,我也做了类似下面的操作
密码必须包含:\n\n至少一个大写英文字母\n\n至少一个小写英文字母\n\n至少一个数字,\n\n至少一个特殊字符(!"#$% &'()*+,-./:;> ;=<?@^_`{|}~)\n\n最少 8 个长度。 -
"\n" 将换行,您可以将字符串放在不同的行中
-
builder2.setMessage("您可以使用您的 garnt 号或 TRN。" +"\n"+ 签证批准号可以在您的签证批准通知中找到。" +"\n"+ "交易参考号可以在您的 ImmiAccount 和部门的任何信件中找到。").....add("\n" 单独的字符串);最好使用自定义对话框..