3

I'm currently being handed a string such as Hello there my\r\nName is\r\nJohn Smith\r\nand\r\nstuff and I want to put each line in a new list item... such as:

Desired Result (List view with separate list items):

Hello there my
--------------
Name is
--------------
John Smith
--------------
and
--------------
stuff

I figured I would be able to parse the entire string by the \r\n to put each line into an array and use an array adapter to set the list view, but it just interprets the \r\n as a new line. So I end up having a text view that looks like this:

Current result (Just one textView):

Hello there my
Name is
John Smith
and
stuff

Is there any way to stop it \r\n from just creating a new line so that I can parse it into an array?

String[] myText = {"Helo there my", "Name is", "John Smith", "and", "stuff"};
4

1 回答 1

1

你试过这个吗?:

String[] myText = originalText.split("\r\n");
于 2013-08-01T03:09:49.893 回答