tags:

views:

457

answers:

3

Hey, im 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 post out here in the Internet is saying that I can do that... Any ideas?

+3  A: 

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.

Christopher
Thx, that was it. Eclipse did not suggest I import that package for some reason =)
Ted
A: 

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.

manuel aldana
They're both public methods in `Activity`: http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged%28android.content.res.Configuration%29
Christopher
A: 

Let me guess. SuperNotCalledException. @Override public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig); setContentView(R.layout.main); }

drago-od