[android]在 Html.fromHtml 中的换行被忽略

来源:互联网 发布:linux操作mysql数据库 编辑:程序博客网 时间:2024/05/20 18:55

我收到一个 API 的文本换行,但我不能换行工作。

这是文本的我想要显示部分。http://pastebin.com/CLnq16mP(粘贴它那里因为计算器上的格式不正确。)

我试着这样:

termsAndConditionsTextView.setText(Html.fromHtml(“” + textResponse.getText() + ““));
和这:

termsAndConditionsTextView.setText(Html.fromHtml(textResponse.getText()));
但总是忽略了换行 (\r\n) 和空格。

如何解决此问题?

解决方法 1:
由于其 html 尝试使用


你可以通过做这样的事情在您的文本替换所有 \r\n 和空格:

//message is your string.message = message.replace("\r\n","<br />");message = message.replace(" "," ");termsAndConditionsTextView.setText(Html.fromHtml(message));
0 0
原创粉丝点击