IntelliJ IDEA 13.1 Web Help

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.

androidResourcesAndRJava.png

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 goto_declaration.png in the left gutter area.
    • Quick fixes including resource creation upon reference failure.
    • Code completion for referencing Android SDK resources.
To create a resource definition file
  1. In the Project view below the res, locate the folder with the resources of the desired type or create a new folder.

    Tip

    Find the list of resource types in the Android documentation.

  2. Right-click the relevant folder and on the context menu, choose New | File.
  3. in the dialog box that opens, type the name of the new definition file with the extension /xml.

    Tip

    Follow the Android documentation naming guidelines.

  4. 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.
  5. Populate the resource definition file as necessary.

See Also

Concepts:

Procedures:

Reference:

Web Resources: