Android开发环境搭建后,新建HelloAndroid工程后,R.layout.main报错,工程报错,求解!
Android开发环境搭建后,新建HelloAndroid工程后,HelloAndroid活动类报错,代码如下:
Java code
package com.android.hello;
import android.R;
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
在setContentView(R.layout.main);行报错,信息如下:
Multiple markers at this line
- Line breakpoint:HelloAndroid [line: 11] - onCreate
(Bundle)
- R
cannot be resolvedctrl+1后会提示导入 import android.R; 包,但是导入这个包后还是报错,报错信息如下:
Multiple markers at this line
- R.layout.main cannot be resolved
- Line breakpoint:HelloAndroid [line: 12] - onCreate
(Bundle)
不知道是我的环境搭建又问题,还是需要再设置什么路径什么的?麻烦各位高手指教下!谢谢
------解决方案--------------------R 引用错误
------解决方案--------------------
import android.R; 去掉这玩意