我想要一個RSS
Feed顯示在Android應用程序中。基本上,它當然是從XML
文件中讀取的。我想要在Android listView
:title
,description
中顯示兩個項目。Java/Android中的RSS提要佈局
我想進這樣做:
title
description
title
description
title
description
title
description
相反,它是這樣做的:
title
title
title
title
title
title
description
description
description
description
description
description
我能看到爲什麼在此基礎上的代碼是怎樣的,但我想不出如何佈局像實施例編號1
這裏是代碼:
private class RSSHandler extends DefaultHandler {
public void startElement(String uri, String localName, String qName,
Attributes attrs) throws SAXException {
if (localName.equals("item")) {
item = true;
}
if (localName.equalsIgnoreCase("title")) {
fTitle = true;
}
if (localName.equalsIgnoreCase("description")) {
fDesc = true;
}
}
public void endElement(String namespaceURI, String localName,
String qName) throws SAXException {
}
public void characters(char[] ch, int start, int length)
throws SAXException {
if (fTitle) {
titleResult = titleResult + (new String(ch, start, length))
+ "\t\n\n";
fTitle = false;
}
if (fDesc) {
rssResult = rssResult + (new String(ch, start, length))
+ "\t\n\n";
fDesc = false;
}
}
}