IntelliJ IDEA provides a number of facilities for managing
resources used in Android applications.
In the project view, resource definition files are shown grouped into folders under the
Resources are accessed through the
R.java class, which is generated upon project creation
and re-generated each time you save your project. In the project view,
R.java is displayed
gen folder under the relevant destination package.
The following coding assistance is provided:
- Basic code completion.
- Code completion for various resource types, including alternate resources.
- Syntax and error highlighting.
- Find usages.
- Code completion when referencing resources from other resources.
- Integration between the resources and
- Adding a reference to a newly created resource automatically.
- Find usages from
R.javaand navigation to the usages from the Find tool window.
- Navigation between a reference to a resource in
R.javaand the resource definition by clicking the Go to icon in the left gutter area.
- Quick fixes including resource creation upon reference failure.
- Code completion for referencing Android SDK resources.
- Extract style refactoring (see Refactoring Android XML Layout Files for details).
- Extract layout refactoring (see Refactoring Android XML Layout Files for details).
- Extract string resource intention (see Refactoring Android XML Layout Files for details).
To create a resource definition file
- In the Project view under the
resfolder, locate the folder with the required resources, or create a new folder.
- Right-click the relevant folder and select New | File from the context menu.
- in the dialog box that opens, type the name of the new
- To enable coding assistance, in the root element, specify the
http://schemas.android.com/apk/res/androidschema as the value of the
- Populate the resource definition file as necessary.