日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
AndroidXML提要怎么實(shí)現(xiàn)

本篇內(nèi)容介紹了“Android XML提要怎么實(shí)現(xiàn)”的有關(guān)知識,在實(shí)際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)公司專注于贛縣企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,電子商務(wù)商城網(wǎng)站建設(shè)。贛縣網(wǎng)站建設(shè)公司,為贛縣等地區(qū)提供建站服務(wù)。全流程按需網(wǎng)站策劃,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)

通過允許日期和鏈接作為簡單的對象被訪問,同時將它們表示為較強(qiáng)類型的對象(de  >java.util.Datede > 和 de >java.net.URLde  >),它隱藏了一些內(nèi)部狀態(tài)。它是一個典型的 Value Object,因此它基于其內(nèi)部狀態(tài)實(shí)現(xiàn)了 de >equals()de  > 和 de >hashCode()de >。它還實(shí)現(xiàn)了 de >Comparablede >  接口,因此您可以使用它進(jìn)行排序(按日期)。在實(shí)踐中,提要中的數(shù)據(jù)始終是有序的,因?yàn)闆]有必要再進(jìn)行排序。

每個解析器實(shí)現(xiàn)都需要提供一個 URL 給 Androidster 提要,并使用它打開一個到 Androidster 站點(diǎn)的 HTTP 連接。這一常見行為自然是在 Java 代碼中建模,我們使用了一個抽象基類,所示。

基本提要解析器類

java代碼:

public abstract class BaseFeedParser implements FeedParser { // names of the XML tags static final String PUB_DATE = "pubDate"; static final String DESCRIPTION = "description"; static final String LINK = "link"; static final String TITLE = "title"; static final String ITEM = "item"; final URL feedUrl; protected BaseFeedParser(String feedUrl){ try { this.feedUrl = new URL(feedUrl); } catch (MalformedURLException e) { throw new RuntimeException(e); } } protected InputStream getInputStream() { try { return feedUrl.openConnection().getInputStream(); } catch (IOException e) { throw new RuntimeException(e); } } }

基類存儲 de >feedUrlde > 并使用它打開了一個 de >java.io.InputStreamde  >。如果出現(xiàn)任何差錯,它會拋出一個 de >RuntimeExceptionde  >,造成應(yīng)用程序出現(xiàn)故障?;愡€為標(biāo)記的名稱定義了一些簡單的常量。顯示了提要中的一些示例內(nèi)容,以便于您理解這些標(biāo)記的重要性。

示例 XML 提要

java代碼:

  1. < ?xml version="1.0" encoding="UTF-8"? > 

  2. < !-- generator="FeedCreator 1.7.2" -- > 

  3. < rss version="2.0" > 

  4. < channel > 

  5. < title >android_news< /title > 

  6. < description >android_news< /description > 

  7. < link >< /link > 

  8. < lastBuildDate >Sun, 19 Apr 2009 19:43:45 +0100< /lastBuildDate > 

  9. < generator >FeedCreator 1.7.2< /generator > 

  10. < item > 

  11. < title >Samsung S8000 to Run Android, Play DivX, Take Over the World< /title > 

  12. < link >< /link > 

  13. < description >More details have emerged on the first Samsung handset 

  14. to run Android. A yet-to-be announced phone called the S8000 is being 

  15. reported ...< /description > 

  16. < pubDate >Thu, 16 Apr 2009 07:18:51 +0100< /pubDate > 

  17. < /item > 

  18. < item > 

  19. < title >Android Cupcake Update on the Horizon< /title > 

  20. < link >< /link > 

  21. < description >After months of discovery and hearsay, the Android 

  22. build that we have all been waiting for is about to finally make it 

  23. out ...< /description > 

  24. < pubDate >Tue, 14 Apr 2009 04:13:21 +0100< /pubDate > 

  25. < /item > 

  26. < /channel > 

  27. < /rss >

“Android XML提要怎么實(shí)現(xiàn)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!


當(dāng)前題目:AndroidXML提要怎么實(shí)現(xiàn)
鏈接分享:http://www.dlmjj.cn/article/ppsich.html