我正在嘗試處理來自API的XML plist數據,但是碰到很多牆壁!如何從ArrayList中的對象中獲取項目值
數據是蘋果plist格式,我使用Akos的代碼this link解析,這似乎很好地工作。它解析爲String,Object到HashMap中。我能夠得到給定鍵的值,即。
Object childItems = items.mPlistHashMap.get("childItems");
System.out.println(childItems.getClass());
System.out.println(childItems);
childItems.getClass()示出了如 - 類java.util.ArrayList
的logcat的輸出爲childItems示出 - [{remoteFilePath =/Picture.png,主機= www.host .com,ratingCount = 1,targetId = 82,commentCount = 1,externalId =/demo.host.com/Private/Picture.png,fileSize = 23738,entity_name = Item,memberAccessLevel = 0,leaderAccessLevel = 0,name =圖片。 png,target = SystemUser,ownerAccessLevel = 3,tagCount = 1},{lastName = Test,entity_name = User,username = Test,host = www.host.com,userId = 82,firstName = Test,password = TestPwd,loginName =測試},{typeId = 0,entity_na我= UserType,名稱= UserType_Teacher}]
我認爲我可以然後使用此ArrayList,但這是我未來的地方。例如,我想獲取remoteFilePath值,並將其顯示在ListView中(已經爲本地文件工作)。
上面的示例childItems列表只包含一個文件(Picture.png),但該列表可能包含任意數量的文件,因此我需要迭代列表並獲取remoteFilePath的任何值以顯示。
任何幫助表示讚賞,我只是不知道如何「沮喪」到這個列表中,或者如果childItems對象需要被轉換爲一個新的Array等等。
如果我錯過任何重要信息,問我應提供:)