Why can't I override onConfigurationChanged (Configuration)?

I already saw a similar question here , and I already added the line import android.content.res.Configuration; . However, this did not help.

I am writing a class that extends AdapterView<Adapter> , and Eclipse will not allow me to override onConfigurationChanged(Configuration) . As seen on the AdapterView page in Android Docs , the method does exist. So why can't I override it?

Here is my implementation:

 import android.content.Context; import android.content.res.Configuration; import android.view.View; import android.widget.Adapter; import android.widget.AdapterView; public class Foo extends AdapterView<Adapter> { public Foo(Context context) { super(context); // TODO Auto-generated constructor stub } @Override public Adapter getAdapter() { // TODO Auto-generated method stub return null; } @Override public View getSelectedView() { // TODO Auto-generated method stub return null; } @Override public void setAdapter(Adapter adapter) { // TODO Auto-generated method stub } @Override public void setSelection(int position) { // TODO Auto-generated method stub } /* * Error is thrown here... The method onConfigurationChanged(Configuration) of * type Foo must override or implement a supertype method */ @Override protected void onConfigurationChanged(Configuration newConfig) { /* * Error is thrown here... The method onConfigurationChanged(Configuration) is * undefined for the type AdapterView<Adapter> */ super.onConfigurationChanged(newConfig); } } 
+4
source share
2 answers

onConfigurationChanged() was added to the View at API level 8. The goal of your build in Eclipse (or the target in default.properties for the command line) is probably set to a lower API level.

+4
source

onConfigurationChanged is only in the view "C: API Level 8". If you are developing an earlier version, there is no such method, so you cannot override and call them. There is one in "activity", and you can prove that your code will be correct by changing your actions to activity. This will not work for compilation, since you want an adapter, but as a proof of concept for your import, and all this will be :)

0
source

All Articles