@override eclipse annotation

I know that many people ask the same question (and many answer it), but none of their answers help me.

I always get @override annotation errors if I anonymously implement a method from the 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 an Android application as a team. My team uses IDEA while I use eclipse. My team never gets this error. Could this be an eclipse mistake?

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

Error:

 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 someone suggest something that could be done to remove this error?

EDIT: more information, I would not get an 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; } 
+6
source share
1 answer

I had this problem several times when importing a project from existing code. For some reason, the JDK compliance level defaults to Java 1.5, even if 1.6 is installed on your computer. If so, 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

+10
source

Source: https://habr.com/ru/post/922926/


All Articles