主页 > 未分类 > Android Error:main cannot be resolved or is not a field

Android Error:main cannot be resolved or is not a field

R.layout.main总是在layout上有错误提示波浪线。

解决方法:

(1) 删除"import android.R;".
(2) 勾选上Eclipse中的"Project->Build Automatically";

原因是:

添加文件,比如xml文件或者资源文件时,系统自动添加了import android.R;android.R是系统提供的资源,R是应用程序的资源。删除"import android.R"之后工程就是从/res文件夹下自动生成的资源文件里去解析了,否则它会从Android的资源类里去找。

 

转自 http://hi.baidu.com/mycollection/item/b458380e566ba8cf905718ac

发表评论

邮箱地址不会被公开。 必填项已用*标注