How can I read breaks in downloaded text?

ぐ巨炮叔叔 提交于 2019-12-12 12:15:42

问题


I'm using the Last.fm Java library that's listed in the "Downloads" section on the API. When I call "getWikiText()" and set it to my TextView, all the data is returned; however, the html isn't formatted correctly. Rather than showing separate paragraphs, the data is shown as one large text. To illustrate what I mean, here is a picture of what is being returned and then a link to the artist page of how things should look.

Picture - http://i.imgur.com/ameTO.jpg

How things should look - http://www.last.fm/music/Bon+Iver

This is what I'm calling to get the artist info, but what am I missing as to the paragraph spacing? I've search around quite a bit, but there's not much information on this in particular. I'm basically shooting in the dark at this point, so I need a little help.

artistInfo = Artist.getInfo("Bon Iver",key);
artistText = artistInfo.getWikiText();
info.setText("");
info.append(Html.fromHtml((artistText)));

回答1:


Do a simple replaceAll() call is enough:

String artistText = artistInfo.getWikiText();
artistText = artistText.replaceAll("\n", "<br />");
info.setText(Html.fromHtml(artistText));



来源:https://stackoverflow.com/questions/9146469/how-can-i-read-breaks-in-downloaded-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!