简体   繁体   English

Java Android 2.3.3,如何从XML文件加载多个数据?

[英]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.

相关问题 Android Studio 2.3.3不会从JAR加载类文件 - Android Studio 2.3.3 won't load class file from JAR 如何从Java项目加载XML文件? - How to load XML file from a Java project? 如何使用JSON从远程数据库检索数据并显示在android应用程序xml文件中? - How do i retrieve the data using JSON from the Remote Database and display in my android app xml file? 如何将数据从 Java 对象加载到 Kudu 表? - How do I load data from a Java object to Kudu table? Android:如何在本地 JSON 文件中显示来自多个字符串数组的数据? - Android:How do I display data from multiple array of strings in a local JSON file? 使用Java,我将如何从网站读取xml文件,然后将xml文件中的数据放入JList中? - Using java, how would I read an xml file from a website then put the data from the xml file in a JList? 如何从属性文件中指定的XML文件加载Spring bean定义? - How do I load Spring bean definitions from XML file specified in a properties file? 在Java中,如何一次从文件中迭代多个元素? - In Java, how do I iterate multiple elements at a time from a file? 我们如何动态地将数组从Java文件添加到android中现有的xml文件中? - How do we dynamically add an array from a java file to an existing xml file in android? 如何使用Java(Android)从网站抓取数据? - How do I scrape data from a website using Java (Android)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM