MyClass extends Activity implements OnClickListener

15 views
Skip to first unread message

Frits Kruis

unread,
Nov 1, 2012, 6:02:34 PM11/1/12
to java-id...@googlegroups.com
Hi,

I have Activity.java which implements:

public class WriteSDActivity extends Activity implements OnClickListener
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.clear_button).setOnClickListener(this);
findViewById(R.id.save_button).setOnClickListener(this);
findViewById(R.id.load_button).setOnClickListener(this);
}
    @Override
    public void onClick(View v) {
        switch(v.getId()) {
            case R.id.clear_button:
                ((EditText) findViewById(R.id.first_input_line)).setText("");
                ((EditText) findViewById(R.id.second_input_line)).setText("");
break;
case R.id.load_button:
                load();
                break;
            case R.id.save_button:
                save();
                break;
        }
    }

This works OK under linux but when I try to compile this on Java-ide it gives an error

The method onClick(View) of type WriteSDActivity must overide a superclass method

Does it not see the implement in the class declaration?

What to do

Thanks Frits


Tom

unread,
Nov 2, 2012, 11:21:10 AM11/2/12
to java-id...@googlegroups.com
Hello Frits

I have seen such messages before.
It depends on the target version you define in the compiler options.
I think, if you define -1.6 it should work, otherwise remove the annotation @Override

Tom

Frits Kruis

unread,
Nov 2, 2012, 1:25:12 PM11/2/12
to java-id...@googlegroups.com
Hi Tom,
I assume I change the compile.bsh file and have changed

args = "-depreciation -1.6";

This gives an error 'org.eclipse.jdt.internal.compiler..........
removing the @override works

Thanks
Frits
Reply all
Reply to author
Forward
0 new messages