如果字符串太长,是否可以在警告对话框中显示所有文本?当它太长时,对话框不会显示整个消息,而是显示 elipsis ...
我的代码是:
builder = new AlertDialog.Builder(this);
builder.setMessage("Do you want to play the game again.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//Do Something for OK
}
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//Do Something for No
}
}
});
alert = builder.create();
alert.show();
答案 0 :(得分:1)
创建ScrollView并将其添加到AlertDialog,然后在其中显示您的文本。类似的东西:
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
String str = getString(R.string.text);
final ScrollView s_view = new ScrollView(getApplicationContext());
final TextView t_view = new TextView(getApplicationContext());
t_view.setText(str);
t_view.setTextSize(14);
s_view.addView(t_view);
alertDialog.setTitle("Title");
alertDialog.setView(s_view);
此处ScrollVies包含一个TextView,其中包含R.string.test
的文本,并且ScrollView被设置为对话框的内容视图。
答案 1 :(得分:0)