Resources and Configuration Changes

Resources help with localization. For example, you can have a string value that changes based on the language locale of the user. Android resources generalize this idea to any configuration of the device, of which language is just one configuration choice. Another example of a configuration change is when a device is turned from a vertical position to a horizontal position. The vertical mode is called the portrait mode and the horizontal mode the landscape mode.

Android allows you to pick different sets of layouts based on this layout mode for the same resource ID. Android does this by using different directories for each configuration. An example is shown in Listing 3–36.

Listing 3–36. Alternate Resource ...

Get Pro Android 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.