• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ID resource in Android XML

 
Peter Sorotokin
Ranch Hand
Posts: 36
1
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In the tutorial that i am reading says :

Any View object may have an integer ID associated with it, to uniquely identify the View within
the tree. When the application is compiled, this ID is referenced as an integer, but the ID is
typically assigned in the layout XML file as a string, in the id attribute. This is an XML attribute
common to all View objects (defined by the View class) and you will use it very often. The
syntax for an ID, inside an XML tag is:
android:id="@+id/my_button"
The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and
expand the rest of the ID string and identify it as an ID resource . The plus-symbol (+) means that
this is a new resource name that must be created and added to our resources (in the R.java file).

My question is this : In phrase ID resource , the resource word what does mean ???

Thanks for your helps
 
fahimeh hashemian
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I think 'Resource' refer to your view. for example, you have a Button with resource id=btn, purpose of resource in this is Button. I mean Resource in this, refer to your Button.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that the build system will create an ID of that name automatically (in a file called R.java), which you can use in your code to refer to that object, something like:

Button myButton = (Button) view.findViewById(R.id.my_button)

More detail can be found in http://developer.android.com/guide/topics/resources/accessing-resources.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic