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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.