This is in relation to a previous question I asked here. Calling replaceAll("\n", "<br />") and then Html.fromHtml() will properly format the text in pre-Ice Cream Sandwich; however, as you can see from the photo it does not work in ICS. I’ve tried at least thirty different ways to capture and replace the line breaks in the text, but I come up empty handed. Is there something in particular I need to call in ICS, is this a bug, has anyone else experienced this problem? Can anyone think of a work around, because there’s got to be one. Also, can anyone offer some insight as to why this may be happening? It’s very peculiar.
To be clear: I’ve tested this on Froyo and Gingerbread and the text formatted properly. In Ice Cream Sandwich, it does not.
Here’s an example of the text being returned from Last.fm. Scroll to the bottom, it starts at “content”. Bon Iver URL
Here’s a demo app if you’re interested in testing it first hand. http://dl.dropbox.com/u/2301775/lastfm-api-test.zip
Here are two screenshots illustrating what I mean. They are from the test app. The first running Gingerbread and the second running Ice Cream Sandwich.
(removed old entry… tested the test project)
There is a extremely interesting “issue” but I am not sure who is responsible for it.
I tested your app and got it working.
I was looking on a 2.2 device, where the first
\nappears (index 413) in the string and than I took a look at this index at the ICS version. There I could only find a\r.You can see the difference in the LogCat, too. On ICS you see scrambled text with no sense but below ICS you can read the complete text without any problem.
So instead of replacing
\nwith<br/>you should replace\r, too. I would, just to make sure, replace in this order:\n\r\n\rStep 1 is important to remove the possibility, that you “double” the breaks if someone uses the
\n\r…Used working code: