XML resources of an Android App

There are two kinds of resources: value resource or resource file.

You can call the resource by its id in Java code. To do so, add android:id="@+id/id_name" to the layout area and the id will be added to R.id in R.java.

  1. Define a value resource in folder: res/values/resource_type.xml. E.g. a string resource is defined in res/values/strings.xml like this

Use a resource to populate an android attribute:

  1. Define a resource file in res/resource_type/resource_name.xml.

  2. We can have a general resource called item in resource_type.xml:

value of the item

All resources can be used in java by reference its type and name: R.resource_type.resource_name, such as: