How can I read breaks in downloaded text?

I use the Last.fm Java library specified in the Downloads section of the API. When I call getWikiText () and install it on my TextView, all the data is returned; however, the html is not formatted correctly. Instead of showing separate paragraphs, the data displayed as one large text.To illustrate what I mean, here is an image of what is being returned, and then a link to the artist’s page, how it should look.

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

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

This is what I call to get information about the artist, but what am I missing regarding the paragraph spacing? I searched quite a lot, but there is not much information about this. I'm currently shooting in the dark, so I need a little help.

artistInfo = Artist.getInfo("Bon Iver",key); artistText = artistInfo.getWikiText(); info.setText(""); info.append(Html.fromHtml((artistText))); 
+4
source share
1 answer

A simple call to replaceAll() enough:

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

Example result

+1
source

Source: https://habr.com/ru/post/1394826/


All Articles