1

I've trying to load another developer's Android project into Eclipse. The import is successful, but I get several errors like this:

The method onClick(View) of type new View.OnClickListener(){} must override a superclass method

The offending lines look like this:

findViewById(R.id.random).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

Any ideas?

Joe Mornin
  • 8,766
  • 18
  • 57
  • 82
  • Possible solution here: http://stackoverflow.com/questions/1678122/must-override-a-superclass-method-errors-after-importing-a-project-into-eclipse – MByD Apr 21 '11 at 17:46

1 Answers1

2

I think the problem is that you're using not the newest Java version. OnClickListener is a interface that has the method onClick. The override annotation was used in Java below 6 to mark methods that are overwriten in subclasses. In Java 6 it is also possible to use @Override for implemented methods. So I assume that you're developing for Java 5 while the author author was using Java 5.

To resolve this you have to either remove the @Override annotation or to set the preferences in your IDE to Java 6.

RoflcoptrException
  • 51,941
  • 35
  • 152
  • 200