导入项目到Eclipse后'必须覆盖一个超类方法“错误 [英] 'Must Override a Superclass Method' Errors after importing a project into Eclipse
问题描述
每当我不得不重新导入我的项目到Eclipse(如果我重新安装Eclipse或改变项目的位置),我的重载方法的几乎所有的格式不正确,导致错误必须重写超类方法,该方法
。
Anytime I have to re-import my projects into Eclipse (if I reinstalled Eclipse, or changed the location of the projects), almost all of my overridden methods are not formatted correctly, causing the error The method must override a superclass method
.
这可能是值得提及这是与Android项目 - 不管出于什么原因,总是不填充方法的参数值,所以我必须手动填充他们自己。例如:
It may be noteworthy to mention this is with Android projects - for whatever reason, the method argument values are not always populated, so I have to manually populate them myself. For instance:
list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
//These arguments have their correct names
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
}
});
最初将填充像这样的:
will be initially populated like this:
list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
//This methods arguments were not automatically provided
public void onCreateContextMenu(ContextMenu arg1, View arg2,
ContextMenuInfo arg3) {
}
});
奇怪的是,如果我删除我的code,并有Eclipse将自动重建方法,它使用相同的参数名我已经有了,所以我真的不知道是哪里的问题,其他的则自动格式化的方法适合我。
The odd thing is, if I remove my code, and have Eclipse automatically recreate the method, it uses the same argument names I already had, so I don't really know where the problem is, other then it auto-formatting the method for me.
这变得相当不必手动重建所有我的覆盖方法,通过手的疼痛。如果任何人都可以解释为什么出现这种情况或如何解决它。我会很高兴。
This becomes quite a pain having to manually recreate ALL my overridden methods by hand. If anyone can explain why this happens or how to fix it .. I would be very happy.
也许是由于我格式化的方法,这是另一种方法的一个参数
Maybe it is due to the way I am formatting the methods, which are inside an argument of another method?
推荐答案
Eclipse正在默认为Java 1.5中,你有类实现接口的方法(在Java 1.6的可以用@Override进行注释,但在Java 1.5只能适用的方法覆盖父类的方法)。
Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be applied to methods overriding a superclass method).
转到您的项目/ IDE preferences和Java编译器级别设置为1.6,并且确保你选择的JRE 1.6,从偏食执行程序。
Go to your project/ide preferences and set the java compiler level to 1.6 and also make sure you select JRE 1.6 to execute your program from eclipse.
这篇关于导入项目到Eclipse后'必须覆盖一个超类方法“错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!