eclipse eclipse中的“意图无法解析为类型”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11804112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Intent cannot be resolved to a type' error in eclipse
提问by Joseph Dykstra
I am programming the first android tutorialin eclipse, and when compiling this code:
我正在eclipse 中编写第一个android 教程,并且在编译此代码时:
Intent intent = getIntent();
it gives the error
它给出了错误
Intent cannot be resolved to a type
意图无法解析为类型
How do I fix it?
我如何解决它?
回答by Yogu
Probably, the import
statement is missing. Try pressing Ctrl+Shift+O, Eclipse will automatically add the import statement if missing.
很可能,import
声明丢失了。尝试按Ctrl+ Shift+ O,如果缺少,Eclipse 会自动添加导入语句。
Then look at the top of the file and see what has been added. It should be something like this:
然后查看文件的顶部,看看添加了什么。它应该是这样的:
import android.content.Intent;