简体   繁体   中英

Java Android 2.3.3, how do I load multiple data from an XML file?

I have an XML file in res/values. 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:

<row>
  Name - Picture
  <i>Description</i>
</row>

My question is, how can I store all that information inside my XML file? 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? 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. Is this possible or do I have to add this xml document somewhere else and then parse it somehow?

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. 2- if not create the data base and parse the XML and put in the data base.

Repetitive work:

3- fetching and Update from/in Database is easy and efficient to then writing large data in XML again and again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM