R.java is a good thing, in the Android program development process for you to manage resources, add ID, not very sharp.
But sometimes good things the more delicate, in the writing of Android code, R.java frequently error, make me is physically and mentally exhausted. Several times want to Baidu, Google and other great God to help, but also have their own little experience. If you have a similar problem, you may wish to retrace:
1. Check your code first, the code is wrong, the R.java file is not generated 2. Put the project----> build automatically that option, so that the project will be automatically compiled after each modification, so that the R.java will be up to date (this time the program is wrong, not generated) 3. Project---> Clean, click to select your project, then OK, reset your project settings, and then build again, so that three steps down, you can solve your problem. 4. You can also try, right--android tools-fix properties, which is also a solution in fact, most of the time or the program you did not find errors, especially the writing of XML files, due to the compilation of environmental inspection mechanism is indeed, easy to cause the neglect of errors. It is recommended that the related resources be generated in the XML document before calling R.string or R.id or other R resources, so that the code error rate is much lower.
from:http://blog.csdn.net/xinzhu1990/article/details/7058138
Android's R.java