Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@override annotation in eclipse

I know there are many people asking the same question (and many answering it), but none of their answers are helping me.

I always get @override annotation errors if I'm anonymously implementing a method from an interface.

 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override //  <-- **this will give error message**
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            Menu menu = MainMenu.listMenu.get(i);


            Tabs.setCurrentTab(menu.pos + 1); 
        }
    });

I am developing my android application in a team. My team are using IDEA whilst I am using eclipse. My team never get this error. Could it be eclipse's bug?

Our java version is the same, 1.6. My eclipse version is 3.7.

The error is :

Multiple markers at this line
- The method onItemClick(AdapterView<?>, View, int, long) of type new AdapterView.OnItemClickListener(){} must override a superclass 
 method
- implements android.widget.AdapterView.OnItemClickListener.onItemClick

Can anyone suggest someting that could be done to remove this error?

EDIT : more information, i would not get error in this case :

@Override
    public View getView(int position, View v, ViewGroup parent) {
        try {
            ...
            }

            Menu menu = Menu.getListMenu().get(position);

            if (menu != null){
               ...
            }
        } catch (Exception e) {
          ...
        }

        return v;
    }
like image 585
Marchell Imanuel Avatar asked Aug 15 '12 11:08

Marchell Imanuel


1 Answers

I have had this problem several times when importing a project from existing code. The JDK compliance level for some reason defaults to Java 1.5 even though you have 1.6 installed on your machine. If this is the case, right click on your project in the Eclipse package explorer, select Properties, select the Java Compiler section, and set the JDK Compliance level to 1.6

like image 51
Rich Avatar answered Sep 29 '22 07:09

Rich