1

Possible Duplicate:
Understand the R class in Android

I cant understand why use 'R' Class in android application.

 setContentView(R.layout.main);

Can explain why use R used here.

asked Feb 23, 2012 at 7:02
2
  • 1
    There are n number of similar questions Commented Feb 23, 2012 at 8:41
  • As a noob android developer I started searching the same thing and wound up here. Very helpful question and tagging Commented Oct 31, 2018 at 15:25

7 Answers 7

16

Your question is duplicate of Understand the R class in Android

When your application is compiled, aapt generates the R class, which contains resource IDs for all the resources in your res/ directory. For each type of resource, there is an R subclass (for example, R.drawable for all drawable resources) and for each resource of that type, there is a static integer (for example, R.drawable.icon). This integer is the resource ID that you can use to retrieve your resource.

I got this detail from the below link ,check this once for more details : http://developer.android.com/guide/topics/resources/accessing-resources.html

answered Feb 23, 2012 at 7:06
Sign up to request clarification or add additional context in comments.

Comments

3

R.java which is Automatically System generated file it contains the id of each resources used in Application which is used to make refrence.

answered Feb 23, 2012 at 7:15

Comments

2

R.class contains IDs for all your android resources.

answered Feb 23, 2012 at 7:06

Comments

2

R.class holds reference for all your android resources.. without which you cannot access any resources (drawable, layout, xmls etc) And R.class is Autogenerated.

Parag Chauhan
36k13 gold badges89 silver badges95 bronze badges
answered Feb 23, 2012 at 7:04

Comments

1

R is the class that contains all the resource ids for your application.

answered Feb 23, 2012 at 7:08

Comments

1

Its a resource class, contains ID for for all resources. Here you can also use

 setContentView(main);
Andro Selva
54.4k53 gold badges195 silver badges244 bronze badges
answered Feb 23, 2012 at 7:09

Comments

0
answered Feb 23, 2012 at 7:07

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.