i m new to android i m just trying to load rss(xml data) in to listview,i need to add title and pubdata on listview...i m loading title in listview but not idea how to load pubdate as well..pls help me for the same.....thanxs in advance...
here is a code,,,title is loading sucsessfully,need to load date in listview..on single row
try {
URL url = new URL("rss link <contain title,pubDate tag> ");
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(getInputStream(url), "UTF_8");
boolean insideItem = false;
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (xpp.getName().equalsIgnoreCase("item")) {
insideItem = true;
} else if (xpp.getName().equalsIgnoreCase("title")) {
if (insideItem)
headlines.add(xpp.nextText()); //extract the headline
} else if (xpp.getName().equalsIgnoreCase("link")) {
if (insideItem)
links.add(xpp.nextText()); //extract the link of article
} else if (xpp.getName().equalsIgnoreCase("pubDate")) {
if (insideItem)
pd.add(xpp.nextText()); //extract the pub date of article
}
}else if(eventType==XmlPullParser.END_TAG && xpp.getName().equalsIgnoreCase("item")){
insideItem=false;
}
eventType = xpp.next(); //move to next element
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// Binding data
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_expandable_list_item_1, headlines);
setListAdapter(adapter);
}