我正在尝试创建一个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);
}
答案 0 :(得分:0)
使用自定义对话框布局并使用此代码对其进行充气
Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.referral_code_dialog);
dialog.setCancelable(false);
close = (TextView) dialog.findViewById(R.id.close);
apply = (TextView) dialog.findViewById(R.id.apply);
error = (TextView) dialog.findViewById(R.id.error);
referral = (EditText) dialog.findViewById(R.id.referral_code);
dialog.show();
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
apply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});