Adding New Project Resources

For the game screen, you need to add some new resources:

► String resources for the text on the Button controls as well as the text to display when no questions are available

► Miscellaneous Dimension and Color resources needed to design the game screen controls

► Two XML resources with mock question batches

You should now be comfortable creating any String, Dimension, and Color resources you need for the screen layout, so let's talk for a moment about the mock question batches.

Eventually, the questions used by the Been There, Done That! application will be retrieved from a server on the Internet. However, for now, you can create two batches of mock questions that can be accessed locally as XML: /res/xml/sampleques-tions.xml and /res/xml/samplequestions2.xml. Later, when you add network support to the application, you will retrieve this same XML from a server. By including mock batches of questions now, you can iron out the game logic without worrying about network connectivity.

Regardless of whether the batch of questions is sourced locally or from a remote server, the XML block looks the same. Here is what it looks like:

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

<!— This is a mock question XML chunk —> <questions> <question number="1" text=

"Have you ever been on an African safari?"



<question number="2" text=

"Have you ever climbed a mountain?"



<question number="3" text=

"Have you ever milked a cow?"




As you can see, the XML is very simple. It has one tag called <questions>, which can contain a number of <question> tags. Each <question> tag has three attributes: the question identifier (number), the question itself (text), and the URL to the image associated with the question (imageUrl). Note that you use remote graphics sourced from the Internet instead of adding each and every question graphic to the resources of the application.

Was this article helpful?

0 0

Post a comment