IntelliJ IDEA 14.0.0 Web Help

Managing Resources

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 res directory. 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 in the gen folder under 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.
    • 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

  1. In the Project view under the res folder, locate the folder with the required resources, or create a new folder.
  2. Right-click the relevant folder and select New | File from the context menu.
  3. in the dialog box that opens, type the name of the new .xml definition file.
  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

Last modified: 12 November 2014
comments powered by Disqus