Html.fromHtml(String) + 换行符问题
我想在警报消息中显示带有换行符的文本:
private void showAbout() {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
String message = "<b>Rechtlicher Hinweis:</b>\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a dolor sapien. Etiam arcu erat, lobortis sed vestibulum ut, adipiscing et enim. Nulla vestibulum volutpat dolor, non pellentesque purus imperdiet vitae. Aenean et elit vel erat consectetur pulvinar. Sed semper, ante vel elementum aliquet, dui urna scelerisque tortor, eu auctor lorem nunc adipiscing velit. Praesent eget libero diam, eget imperdiet sem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.\n" + getVersionInfo();
builder.setMessage(Html.fromHtml(message));
builder.setCancelable(false);
builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
builder.setTitle("About");
builder.setIcon(R.drawable.icon);
AlertDialog alert = builder.create();
alert.show();
}
然而,这或多或少工作得很好,换行符
\n
根本不显示。我已经尝试过用甚至替换,但没有任何效果。任何提示如何做到这一点?\n
\\n
<\br>