Reputation: 5391
I've already seen the similar question here, and I have already added the line
import android.content.res.Configuration;
. It hasn't helped though.
I am writing a class that extends AdapterView<Adapter>
, and Eclipse will not let me override onConfigurationChanged(Configuration)
. As seen in the AdapterView page in the Android Docs, the method does indeed 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);
}
}
Upvotes: 4
Views: 2160
Reputation: 64399
The onConfigurationChanged
is in the View only "Since: API Level 8". If you are developing against an earlier version, there is no such method, so you can't override and call them. There is one in "activity", and you can prove your code to be correct by changing your extends into activity. This will not work for compiling ofcourse since you want an adapter, but as a proof of concept for your imports and all it will :)
Upvotes: 0
Reputation: 1006539
onConfigurationChanged()
was added to View
in API Level 8. Your build target in Eclipse (or the target in default.properties
for the command line) probably is set to a lower API level.
Upvotes: 4