I'm trying to override the method onConfigurationChanged and I get the error:
The method onConfigurationChanged(Configuration) of type BaseActivity must override or implement a supertype method
Here is my BaseActivity.java:
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
public class BaseActivity extends Activity
{
protected View.OnClickListener mButtonListenerUPP;
protected View.OnClickListener mButtonListenerALT;
protected View.OnClickListener mButtonListenerNAV;
protected View.OnClickListener mButtonListenerHIS;
@Override
public void setContentView(int layoutResID)
{
super.setContentView(layoutResID);
}
@Override
public void onConfigurationChanged(Configuration newConfig)
{
setContentView(R.layout.main);
}
}
A lot of posts on the Internet are saying th开发者_开发百科at I can override this method... Any ideas?
Have you got android.content.res.Configuration
in your import statements? Eclipse can insert imports automatically if you press Ctrl+Shift+O.
If that's missing, the compiler will be unable to recognise that you're legitimately overriding the superclass method and so will throw an error.
Let me guess. SuperNotCalledException.
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig); // add this line
setContentView(R.layout.main);
}
Maybe there is a problem with the @Override annotation. Are you sure that both methods annotated with @Override are defined in Activity?
If not you have to remove the respective @Override annotation.
精彩评论