main cannot be resolved or is not a field
2015-03-12 15:38
471 查看
setContentView(R.layout.main);
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的资源类里去找。
这可能是问题之一。
但还有一种情况,在res/layout目录下的xml的名称是:activity_main.xml
所以改正方法是:
setContentView(R.layout.activity_main);
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的资源类里去找。
这可能是问题之一。
但还有一种情况,在res/layout目录下的xml的名称是:activity_main.xml
所以改正方法是:
setContentView(R.layout.activity_main);
相关文章推荐
- activity_main cannot be resolved or is not a field
- Android Error:main cannot be resolved or is not a field,异常语句:setContentView(R.layout.main);
- main cannot be resolved or is not a field
- "activity_main cannot be resolved or is not a field"的解决办法
- Eclipse :main cannot be resolved or is not a field (来自 CSDN_ID typename)
- Android Error:main cannot be resolved or is not a field 问题解决方法
- main cannot be resolved or is not a field (来自 CSDN_ID typename)
- activity_main cannot be resolved or is not a field
- activity_main cannot be resolved or is not a field
- Android Error:main cannot be resolved or is not a field
- main cannot be resolved or is not a field
- 1.创建空白工程时候出现“activity_main cannot be resolved or is not a field”错误
- main cannot be resolved or is not a field
- main cannot be resolved or is not a field
- main cannot be resolved or is not a field
- main cannot be resolved or is not a field
- main cannot be resolved or is not a field
- main cannot be resolved or is not a field