[英]Java Android 2.3.3, how do I load multiple data from an XML file?
I have an XML file in res/values. 我在res / values中有一个XML文件。 The file contains a list of people. 该文件包含人员列表。 This is then presented inside a listview. 然后将其显示在列表视图中。 So far, no problems. 到目前为止,没有问题。 But I want to modify my listview to also display a picture for each person and some details. 但是我想修改我的列表视图,以同时显示每个人的图片和一些细节。 The idea is something like this for the listview: 对于listview,想法是这样的:
<row>
Name - Picture
<i>Description</i>
</row>
My question is, how can I store all that information inside my XML file? 我的问题是,如何将所有这些信息存储在XML文件中? Normally that is not a problem, like: 通常这不是问题,例如:
<persons>
<person name="Scott">
<picture>path to asset somehow?</picture>
<desciption>Description of Scott</desciption>
</person>
...
</persons>
But how do I add this into the res/value/persons.xml file? 但是,如何将其添加到res / value / persons.xml文件中? The only thing is like a string-array and I do want Scott's description to end up with Scott and not with someone else. 唯一的事情就像一个字符串数组,我确实希望Scott的描述以Scott而不是以其他人结尾。 Is this possible or do I have to add this xml document somewhere else and then parse it somehow? 这可能吗,还是我必须将此xml文档添加到其他位置,然后以某种方式解析它?
if possible, it would be better to keep this data in database....... 如果可能的话,最好将这些数据保存在数据库中。
One time work: 一次工作:
1- When App start check the databse "DATABSE NAME" Exist or not. 1-启动应用程序时,检查数据库“ DATABSE NAME”是否存在。 2- if not create the data base and parse the XML and put in the data base. 2-如果未创建数据库,则解析XML并将其放入数据库。
Repetitive work: 重复性工作:
3- fetching and Update from/in Database is easy and efficient to then writing large data in XML again and again. 3-从数据库中/从数据库中获取和更新很容易且高效,然后一次又一次地以XML写入大数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.