【发布时间】:2015-01-23 13:55:37
【问题描述】:
我正在开发一个应用程序,在该应用程序中,我使用站点中的 jsoup 解析 XML 文件并将其显示在 textview 上。我遇到的问题是 RSS 中包含的格式说明符 \n 不是 wprking。它没有进入新行,而是按原样显示 \n 。这是我的代码
hello = sb.toString();
String title, description = null;
Document document = Jsoup.parse(hello);
Elements a = document.getElementsByTag("item");
for (Element element : a) {
title = element.child(0).text();
description = element.getElementsByTag("description").get(0).text();
String src = Jsoup.parse(description).select("img").first().attr("src");
String id = Jsoup.parse(description).select("id").text();
description = Jsoup.parse(description).text();
description = description.replace(id, "");
description = description.replace("/", "\\");
list.add(new News(title, id, src, description ));
描述包含 \n 标签,但在文本视图中它不工作,如图所示。正如您在第一行中看到的那样,而不是按原样进入新行 \n 。
【问题讨论】:
-
@TechnoCracker 我是 android 新手.. 你能解释一下吗?
-
你的描述存储在哪里?
-
无处可去。我只是解析并在屏幕上显示它。
-
我给你举个例子... tv1.setText(Html.fromHtml("Name" + "
" + "Chirag Savsani")); -
输出显示后换行 n 换行...
标签: android xml-parsing jsoup format-specifiers