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 below the res directory. Resources are accessed through the R.java class, which is generated upon project creation and re-generated after each Save. In the project view, R.java is displayed in the gen folder below 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 R.java:
- Adding a reference to a newly created resource automatically.
- Find usages from R.java and navigation to the usages from the Find tool window.
- Navigation between a reference to a resource in R.java and 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.
- In the Project view below the res, locate the folder with the
resources of the desired type
or create a new folder.
Find the list of resource types in the Android documentation.
- Right-click the relevant folder and on the context menu, choose .
- in the dialog box that opens, type the name of the new definition file with the extension /xml.
Follow the Android documentation naming guidelines.
- To enable coding assistance, in the root element, specify the http://schemas.android.com/apk/res/android schema as the value of the xmlns:android field.
- Populate the resource definition file as necessary.