我刚刚下载并安装了新的 Android SDK。我想创建一个简单的应用程序来测试它。
向导创建了以下代码:
package eu.mauriziopz.gps;
import android.app.Activity;
import android.os.Bundle;
public class ggps extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
but Eclipse给我错误
R无法解析
on line
setContentView(R.layout.main);
Why?
PS:我有一个名为main.xml
under res/layout/
.
在追踪这个问题之后,我在Android文档中发现了这样的注释:
http://source.android.com/source/using-eclipse.html
*注意:Eclipse 有时喜欢在
使用资源的文件的顶部,
特别是当你要求 Eclipse 时
对进口进行排序或以其他方式管理。这
会导致你的make打破。看
排除这些错误的导入
语句并删除它们。*
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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)