拆分一个字符串,使文本位于彼此下方
我有一个字符串,它将被我的下一堂课中的intentExtra 拾取,并设置为多行TextView 的文本。我想知道是否有一种方法可以将文本分开,这样它们就在彼此的下面,所以我有这个字符串:
maint = "Here is some info about nothing." +
"Some more info about nothing." +
"And a little more about nothing";
所以通常它们会显示在像这样的文本视图中:
Here is some info about nothing. Some more info about nothing. And a little more info about nothing.
有没有一种方法可以让它们在每个文本之后结束该行这些单独的片段被写入 TextView 中,
如下所示:
Here is some info about nothing.
Some more info about nothing.
And a little more about nothing.
对于每个单独的句子来说,使用单独的 TextView 似乎太多了。
提前致谢
i have a string that will get picked up by an intentExtra in my next class and be set as the text for a multiline TextView. i was wodnering if there is a way to split the text up so they are under eachother, so i have this string:
maint = "Here is some info about nothing." +
"Some more info about nothing." +
"And a little more about nothing";
so usually they would be displayed in a textView like this:
Here is some info about nothing. Some more info about nothing. And a little more info about nothing.
is there a way so they would end the line after each one of those separate pieces were written into the TextView
like so:
Here is some info about nothing.
Some more info about nothing.
And a little more about nothing.
it just seems like it would be too much with a separate TextView for each of those separate sentences.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在要换行的位置添加 /n。
您还可以使用 Html 对其进行格式化。在您想要换行的位置添加一个。
如果使用 HTML 格式,则需要先解析它,然后再将其传递给 textview:
Add a /n to where you want to have a newline.
You could also format it using Html. Add a where you want a newline.
If you format it with HTML, you need to parse it first before passing it to the textview:
这应该做你想要的(“\n”是换行符)
This should do what you want ("\n" being a newline character)