結果上網搜了半天,結果是
第一個查到的方法:
很多人碰到創建新工程的時候出現 cannot be resolved to a variable的問題時沒法在第一時間得到最好的解決
其根本原因是r.java文件沒有自動生成
關於一般的解決方案在網上很多人提出來了
比如CLEAN工程,CLEAN UP RESOURCE,Android Tools >> Fix Project Properties 等
但還是部分人看了網上的帖還不能解決,那麼請注意兩點:
1. 如果你在更新下載SDK,那麼先關閉,重啓ECLIPSE便可
2. 如果還不行,則更新完整ADT、SDK
本文出自 “清風柳絮” 博客,請務必保留此出處http://binuu.blog.51cto.com/801317/775781第二個查到的方法:
*Note: Eclipse sometimes likes to add an "import android.R" statement at the top of your files that use resources, especially when you ask Eclipse to sort or otherwise manage imports. This will cause your make to break. Look out for these erroneous import statements and delete them.*
While going through the Android sample tutorials, I would often use the Ctrl + Shift + O command to "Organize Imports" and generate any missing import statements. Sometimes this would generate the incorrect import statement
which would hide the R.java
class that is automatically generated when you build.
自我感覺應該是生成R.java的過程被打斷了或發生了意外,於是刪除原來的項目,重新導入,
哦哦,這次真的就成了!自動產生了R.java文件。呵呵