Now, we will follow that introduction with an in-depth look at Android SDK fundamentals and cover resources , content providers, and intents. These three concepts are fundamental to understanding Android programming and should place you on a solid foundation for the material in subsequent chapters.
You can change a resource without recompiling the application, and a resource in Android is a file or a value that is bound to an executable application.
Every resource has a ID, that you can change the content of the ID without changing the source code.
String resource definitions is in some XML files which reside in the subdirectory as follows:
res/valuesWhen the file is created or updated, the Eclipse ADT plug-in will automatically create or update a Java class in your applications's root package called R.java with unique IDs for the two string resources specified.
R.java just like this:
The two static final ints defined with variable names hello and app_name are the resource IDs that represent the corresponding string resources. You could use these resource iDs anywhere in the source code through the following code structure:
R.string.hello
In Android, the view of a screen is often loaded from an XML file as resource.These XML files are called layout resources. A layout resource is a key resource used in Android UI programming.
setContentView(R.layout.main);
A LinearLayout lays out its children vertically or horizontally.
You will need to define a separate layout file for each screen (or activity). More accurately, each layout needs a dedicated file.
The views defined in layout files are accessible in java code through their resource IDs generated in R.java.
TextView tv = (TextView)this.findViewById(R.id.text1); tv.setText("Try this text instead");
<TextView android:id="@+id/text1" .. </TextView>
3 Resource Reference Syntax
The syntax you use to allocate an id to a resource in the XML file is called resource-reference syntax.
The id attribute syntax in the previous example @+id/text1 has the following formal structure:
@[package:]type/name