Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 3: Understanding Android Resources - Pg. 51

Chapter 3 Understanding Android Resources In Chapter 2, we gave you an overview of an Android application and a quick look at some of its underlying concepts. You also learned about the Android SDK, the Eclipse Android Development Tool (ADT), and how to run your applications on emulators identified by Android virtual devices (AVDs). In this and the next few chapters, we follow that introduction with an in-depth look at Android SDK fundamentals. These fundamentals include resources, content providers, and intents. Android relies on resources for defining UI components in a declarative manner. This declarative approach is not that dissimilar to the way HTML uses declarative tags to define its UI. In this sense, Android is forward thinking in its approach to UI development. Android further allows these resources to be styled and localized. This chapter covers a variety of resources that are available in Android. Understanding Resources Resources play a key role in Android architecture. A resource in Android is a file (like a music file or a file that describes the layout for a window) or a value (like the title of a dialog box) that is bound to an executable application. These files and values are bound to the executable in such a way that you can change them or provide alternatives without recompiling the application. Familiar examples of resources include strings, colors, bitmaps, and layouts. Instead of hard-coding strings in an application, resources allow you to use their IDs instead. This indirection lets you change the text of the string resource without changing the source code. There are many, many resource types in Android. Let's start this discussion of resources with a very common resource: a string. 51