..
In Chapter percedente probably more attentive readers will have noticed R.id.testo1 topic (or R.id.testo2) passed to the method findViewById.
In this chapter we will, in fact, to analyze the contents of the file R.java which plays a role in certain of our applications.
Open, then the file in question and take a look at the source code.
As mentioned in previous chapters, the file is associated R.java a hexadecimal string for each element of our application. Since this class is self-generated at compile time when you create the installation package, you should complete our project at least once to see the correct code within the file.
Opening the file R.java find a structure of the code a little 'detail. In fact the class is declared inside R, and other nested classes are created that define the elements in our application. For example, we find the class that will contain nested loyout a constant like this:
public static final int main = 0x7f030000;This constant identifies the main main.xml our file and hex string will be used by the compiler to make the appropriate associations.
Scrolling down the file structure R.java are also nested class id. Even within this class we will find two constants that identify the two TextView text1 and text2 As. If, for example, we added a third TextView testo3 named after the application is launched automatically will be placed in the file R.java also a constant for this new element.
R.java the file has been presented in this guide for educational purposes only because the programmer never has to change this file in any way. It is for the compiler to add or remove the constants associated to the elements. Note, finally, that the class R is defined using the modifiers public static final (which in fact identify a constant) in that, while running the application, you will not need to change the attributes of this class.
| |
ASP Zero (Ebook)
Learning Microsoft ASP and VBScript from scratch. At only 29 €. |
| |
Javascript (Course)
Complete guide to client-side scripting. From 39 €. |
| |
MySQL (Course)
Management of open-source database. From 39 €. |