tailieunhanh - Android và RSS

1 package ; 2 3 4 import ; 5 import ; 6 import ; 7 8 public class RSSFeed 9 { 10 private String _title = null; 11 private String _pubdate = null; 12 private int _itemcount = 0; 13 private List _itemlist; 14 15 16 RSSFeed() 17 { 18 _itemlist = new Vector(0); 19 } 20 int addItem(RSSItem item) 21 { 22 (item); 23 _itemcount++; 24 return _itemcount; 25 } 26 RSSItem getItem(int location) 27 { 28 return (location); 29 } 30 List getAllItems() 31 { 32 return _itemlist; 33 } 34 int getItemCount() 35 { 36 return _itemcount;. | Android và RSS I package 2 3 4 import 5 import 6 import 7 8 public class RSSFeed 9 10 private String _title null II private String _pubdate null 12 private int _itemcount 0 13 private List RSSItem _itemlist 14 15 16 RSSFeed 17 18 _itemlist new Vector 0 19 20 int addItem RSSItem item 21 22 item 23 _itemcount 24 return _itemcount 25 _ 26 RSSItem getItem int location 27 28 return location 29 30 List getAllItems 31 32 return _itemlist 33 34 int getItemCount 35 36 return _itemcount 37 38 void setTitle String title 39 40 _title title 41 . 42 void setPubDate String pubdate 43 44 _pubdate pubdate 45 46 String getTitle 47 48 return _title 49 50 String getPubDate 51 52 return _pubdate 53 54 55 56 1 package 2 3 import 4 import . 5 import 6 7 8 9 public class RSSHandler extends DefaultHandler 10 11 12 RSSFeed _feed 13 RSSItem _item 14 String _lastElementName 15 boolean bFoundChannel false 16 final int RS S_TITLE 1 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 final int RSS_LINK 2 final int RSS_DESCRIPTION 3 final int RSS_CATEGORY 4 final int RSS_PUBDATE 5 int depth 0 int currentstate 0 Constructor RSSHandler getFeed - this returns our feed when all of the parsing is complete RSSFeed getFeed return _feed public void startDocument throws SAXException initialize our RSSFeed object - this will hold our parsed contents _feed new RSSFeed initialize the RSSItem object - we will use this as a crutch to grab the info from the channel because the channel and items have very similar entries. _item new RSSItem public void endDocument throws SAXException public void startElement String namespaceURI String localName String qName Attributes atts throws SAXException depth

TỪ KHÓA LIÊN QUAN