Generated R Class Contains Resource IDs

As you build your app’s GUI and add resources (such as strings in the strings.xml file or views in the activity_main.xml file) to your app, the IDE generates a class named R that contains nested classes representing each type of resource in your project’s res folder. You can find this class in your project’s gen folder, which contains generated source-code files. The nested classes are declared static, so that you can access them in your code with R.ClassName. Within class R’s nested classes, the IDE creates static final int constants that enable you to refer to your app’s resources programmatically from your code (as we’ll discuss momentarily). Some of the nested classes in class R include:

• class drawable—contains constants for any drawable items, such as images, that you put in the various drawable folders in your app’s res folder

• class id—contains constants for the views in your XML layout files

• class layout—contains constants that represent each layout file in your project (such as, activity_main.xml)

• class string—contains constants for each String in the strings.xml file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.198.183