R能够解决不了 - Android的错误错误、Android

由网友(等风不等你)分享简介:我刚刚下载并安装了最新的Andr​​oid SDK。我想创建一个简单的应用程序来试驾吧。I just downloaded and installed the new Android SDK. I wanted to create a simple application to test drive it.创建了这...

我刚刚下载并安装了最新的Andr​​oid SDK。我想创建一个简单的应用程序来试驾吧。

I just downloaded and installed the new Android SDK. I wanted to create a simple application to test drive it.

创建了这个code向导:

The wizard created this code:

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);
    }
}

但的Eclipse 给我的错误

研究解决不了

在线

setContentView(R.layout.main);

为什么?

PS:我有一个命名的XML文件的main.xml RES /布局/

PS: I do have an XML file named main.xml under res/layout/.

推荐答案

随着在previous答案很好的建议,确保你的Andr​​oid的目标设定:

Along with the great suggestions in the previous answers, make sure your Android target is set:

在您的项目右键单击 选择属性 在左侧菜单中选择Android版 勾选旁边的相应项目一箱构建目标。 单击应用和确定

编辑:一年后我发现了另一个原因。我有一个形象的.jpg我绘制的文件夹具有相同的名称为.png图像。在我的code引用这一形象一定是混淆了程序,并给了R无法得到解决的错误。

A year later I found another cause. I had a .jpg image in my drawable folder with the same name as a .png image. Referencing this image in my code must have confused the program and it gave the "R cannot be resolved" error.

阅读全文

相关推荐

最新文章