From the course: Android Development Essential Training: 1 Your First App

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Implement designs in XML layouts

Implement designs in XML layouts

- [Instructor] When your activity is first displayed to the user, its setContentView method is called. This method accepts an integer value that corresponds to your XML layout file. Behind the scenes, a file is generated named R. The R file holds resource IDs for all of the resources in your resource directory, but you don't have to worry about looking for it. There are rules for how you can access your resources in code. Here's the syntax for accessing your resources in code. For each type of resource, there's an R subclass. For example, R.string for all string resources, and for each resource of that type, there's a static integer. For example, R.string.app underscore name. This integer is the resource ID that you can use to retrieve your resource. The file extension is not included in the reference. Let's give it a try. Let's say you need a drawable resource named, Icon. Which of the following is the correct way…

Contents