Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android TextView HTML中的换行符_Java_Android_Html - Fatal编程技术网

Java Android TextView HTML中的换行符

Java Android TextView HTML中的换行符,java,android,html,Java,Android,Html,可能重复: 我试图用上标和其他文本在三行中表示一个数字,但换行符由于某种原因不起作用 TextView tvAnswer = (TextView)findViewById(R.id.textView_answer); tvAnswer.setText(Html.fromHtml("16<sup>4</sup>" + "istext \nistextonanotherline")); TextView tvAnswer=(TextView)findViewById(R.

可能重复:

我试图用上标和其他文本在三行中表示一个数字,但换行符由于某种原因不起作用

TextView tvAnswer = (TextView)findViewById(R.id.textView_answer);
tvAnswer.setText(Html.fromHtml("16<sup>4</sup>" + "istext \nistextonanotherline"));
TextView tvAnswer=(TextView)findViewById(R.id.TextView\u-answer);
setText(Html.fromHtml(“164”+“istext\nistexterline”);
“\n”不会导致换行,但它没有我需要的“Html.fromHtml”

这也不起作用:

tvAnswer.setText(Html.fromHtml("16<sup>4</sup>" + "istext<br>istextonanotherline"));
tvarse.setText(Html.fromHtml(“164”+“istext
istextonanotherline”);

因为Android显然不支持br HTML标记。帮助?

一种可能的解决方案是

tvAnswer.setText(Html.fromHtml("16<sup>4</sup>" + "istext "));
    tvAnswer.append("\n");
tvarse.setText(Html.fromHtml(“164”+“istext”));
tvAnswer.append(“\n”);

您可能想看看下面的主题:是的,但我不确定是否有比“CDATA”更好的方法来进行休息。