我怎样才能阅读下载的文本中断? [英] How can I read breaks in downloaded text?

查看:167
本文介绍了我怎样才能阅读下载的文本中断?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是这样的下载一节中列出的Last.fm Java库在API。当我打电话getWikiText(),并将其设置为我的TextView,所有的数据被返回;但是,HTML格式不正确。而不是表示单独段落中,数据被示出为一个大的文本。为了说明我的意思,这里是返回什么图片,然后对事物应该是什么样子的艺术家页面的链接。

照片 - http://i.imgur.com/ameTO.jpg

事情应该如何看待 - http://www.last.fm/music/Bon+Iver

这是我打电话让艺术家的信息,但我是什么失踪的段落间距?我已经四处搜寻了不少,但有没有这么多的信息,尤其如此。我基本上在黑暗中在这一点上拍摄的,所以我需要一点点帮助。

  artistInfo = Artist.getInfo(苯教艾弗键);
artistText = artistInfo.getWikiText();
info.setText();
info.append(Html.fromHtml((artistText)));


解决方案

做一个简单的的replaceAll()调用是不够的:

 字符串artistText = artistInfo.getWikiText();
artistText = artistText.replaceAll(\\ n,< BR />中);
info.setText(Html.fromHtml(artistText));

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)));

解决方案

Do a simple replaceAll() call is enough:

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

这篇关于我怎样才能阅读下载的文本中断?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆