Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有多个空格的字符串,我想根据该字符串的空格在不同行的文本视图中显示该文本。我该怎么做?
TextView text=(TextView)findViewById(R.id.text); text.setText("test1\ntest2\ntest3\ntest4\ntest5\ntest5");
不管你能不能告诉我断线
</ br> or </br>.
让我试试 :
String mystring="Hello How are you?"; mytextview.setText(mystring.replace(" ", "\n"));
您可以使用"\n"在下一行显示文本。
"\n"
例如"This is firstline.\n This is second line"
"This is firstline.\n This is second line"
您可以使用 textview 的 setText() 并将此字符串作为参数传递。
现在,由您决定在 textview 中显示的方式和内容。