AdSense

AdSense3

Wednesday 15 July 2015

Android R.java file

Android R.java is an auto-generated file by aapt (Android Asset Packaging Tool) that contains resource IDs for all the resources of res/ directory.

If you create any component in the activity_main.xml file, id for the corresponding component is automatically created in this file. This id can be used in the activity source file to perform any action on the component.

Note: If you delete R.jar file, android creates it automatically.

Let's see the android R.java file. It includes a lot of static nested classes such as menu, id, layout, attr, drawable, string etc.
  1. /* AUTO-GENERATED FILE.  DO NOT MODIFY. 
  2.  * 
  3.  * This class was automatically generated by the 
  4.  * aapt tool from the resource data it found.  It 
  5.  * should not be modified by hand. 
  6.  */  
  7.   
  8. package com.example.helloandroid;  
  9.   
  10. public final class R {  
  11.     public static final class attr {  
  12.     }  
  13.     public static final class drawable {  
  14.         public static final int ic_launcher=0x7f020000;  
  15.     }  
  16.     public static final class id {  
  17.         public static final int menu_settings=0x7f070000;  
  18.     }  
  19.     public static final class layout {  
  20.         public static final int activity_main=0x7f030000;  
  21.     }  
  22.     public static final class menu {  
  23.         public static final int activity_main=0x7f060000;  
  24.     }  
  25.     public static final class string {  
  26.         public static final int app_name=0x7f040000;  
  27.         public static final int hello_world=0x7f040001;  
  28.         public static final int menu_settings=0x7f040002;  
  29.     }  
  30.     public static final class style {  
  31.         /**  
  32.         Base application theme, dependent on API level. This theme is replaced 
  33.         by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
  34.      
  35.  
  36.             Theme customizations available in newer API levels can go in 
  37.             res/values-vXX/styles.xml, while customizations related to 
  38.             backward-compatibility can go here. 
  39.          
  40.  
  41.         Base application theme for API 11+. This theme completely replaces 
  42.         AppBaseTheme from res/values/styles.xml on API 11+ devices. 
  43.      
  44.  API 11 theme customizations can go here.  
  45.  
  46.         Base application theme for API 14+. This theme completely replaces 
  47.         AppBaseTheme from BOTH res/values/styles.xml and 
  48.         res/values-v11/styles.xml on API 14+ devices. 
  49.      
  50.  API 14 theme customizations can go here.  
  51.          */  
  52.         public static final int AppBaseTheme=0x7f050000;  
  53.         /**  Application theme.  
  54.  All customizations that are NOT specific to a particular API-level can go here.  
  55.          */  
  56.         public static final int AppTheme=0x7f050001;  
  57.     }  
  58. }  

No comments:

Post a Comment