R无法解析
package com.ustr.eMIRnew;
import java.util.ArrayList;
import java.util.HashMap;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class eMIRnew extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}`
这是我的代码。但它显示错误R无法解析
。
我尝试了很多方法,例如清理并构建、关闭并打开项目、将 import android.R
更改为 import your.package.name.R
等。但没有任何帮助。有人可以帮我吗?
package com.ustr.eMIRnew;
import java.util.ArrayList;
import java.util.HashMap;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class eMIRnew extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}`
This is my code. But it is showing the error R cannot be resolved
.
I have tried many methods like clean-and-build, closed-and-open the project, changed import android.R
to import your.package.name.R
etc. But nothing helped. Can anybody help me, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在导入 android.R 包,这是 Android 提供的默认包。
如果你想访问自己的Layout、assets、String。 。 。然后
删除
import android.R语句。
无需导入Package.R,默认情况下,R文件是在构建过程中生成的。
You are Importing android.R package, which is default one provided by Android.
If you want to access your own Layout, assets, String. . . then
Remove the
import android.R statement.
No need to import your Package.R, By default, R file is generated during built.
您正在使用 android R 文件,如果您想访问应用程序的主布局,则必须使用包 R 文件。导入 you_package.R
You are using the android R file you have to use you package R file if you want to access the main layout for you app. import you_package.R
删除导入语句:
在将内容视图设置为 R.layout.main 的 onCreate 方法中,您的项目应该使用此文件:
此文件是在构建项目时生成的。您使用 Eclipse 进行构建吗?那么这应该不是问题。
Remove the import statement:
In the onCreate method where you set the content view to R.layout.main, your project should be using this file:
This file is generated when you build your project. Are you using Eclipse for building? Then this should not be a problem.