Adding New Project Resources

In addition to the new string, color, and dimension resources you use in the scores screen layout, you must also add a new type of resource: an XML file resource file.

The scores for the Been There, Done That! application will eventually be sourced from a remote server, but for now, you can build the screen and use some mock score data. This mock score data will be provided in XML, so you can mimic the structure you will use when the real scores are available.

In this instance, you include in the /res/xml/ resource directory two XML files— allscores.xml and friendscores.xml—that represent the mock score data:

<?xml version="1.0" encoding="utf-8"?>

<!— This is a mock score XML chunk —> <scores> <score username="L£D" score="12345" rank="1" /> <score username="S/AC" score="12344" rank="2" /> <score username="M4D" score="12339" rank="3" /> </scores>

The score data uses a very simple schema. A single <scores> element has a number of child <score> elements. Each <score> element has three attributes: username, score, and rank. For this example, you can assume that the score data will be sorted and limited to the top 20 or so scores.

0 0

Post a comment