http://developer.android.com/guide/topics/resources/accessing-resources.html
>>> 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 Rsubclass (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. <<< You need to add the import for your application's R.java file. In Eclipse, press Ctrl+Shift+O, then select <your package name> R.java, if prompted. Or add "import R.java" manually in the imports section, near the top of the file. -- Kostya 10 января 2012 г. 0:53 пользователь dev0708 <[email protected]> написал: > I don't understand the "findViewById(R.id.myWidget)" syntax. I've > searched for an explanation and only found more advanced topics. > > In graphic layout of main.xml I add a button and edit ID to "@+id/ > myButton" and edit text to a new string. > > I assume that somewhere an ID is recorded, similar to strings.xml that > holds the strings. > > But in the .java file when I do this: > Button myButton = (Button)findViewById(R.id.myButton); > the "id" shows an error (red squiggle). > > Is my concept of storage of IDs wrong? > Where are ID's stored? (Or is this beyond what a beginner should be > thinking about?) > How can I get the "id" in above line of code to recognize the > collection of IDs? > > Much thanks. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

