Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The method onClick(View) of type oddg must override a superclass method?

I am occurring error like:

"The method onClick(View) of type oddg must override a superclass method".

I am confused where exactly error has occurred. Can you please guide me, what exactly error is?

public class oddg extends Activity implements OnClickListener
{
        ProgressDialog dialog;
        int increment;
        int maximum ;
        private static final String TAG = "ServicesDemo";

        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main1);
            Button startbtn = (Button) findViewById(R.id.startbtn);
            startbtn.setOnClickListener(this);

        }

        @Override
        public void onClick(View arg0)
        { }
}

This is my code... Thanks in Advance-- Onkar

like image 867
Smith Avatar asked Apr 25 '11 07:04

Smith


2 Answers

I think the problem is that you're compiler settings are set to Java 1.5 instead of Java 1.6. Since Java 1.6 the annotation @Override is not only possible for inherited methods from a superclass but also for implemented methods from an interface. But if your compiler is still set to 1.5 the problem is that he will check if you're overwriting a method from a super class. In your example this is not the case since you're implementing a method from an interface.

As a side note it would be good to follow Java Naming Conventions in your code. So all classes begin with an upper case letter.

like image 126
RoflcoptrException Avatar answered Nov 07 '22 23:11

RoflcoptrException


I had the same trouble and I fixed it like this:

  • Open Project settings->Java Compiler
  • Set Enable Project Specific Settings to disable
like image 9
Dmitry Nelepov Avatar answered Nov 07 '22 22:11

Dmitry Nelepov