为什么我不能覆盖onConfigurationChanged? [英] Why can't I override onConfigurationChanged?

查看:159
本文介绍了为什么我不能覆盖onConfigurationChanged?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图覆盖的方法 onConfigurationChanged 和我得到的错误:

I'm trying to override the method onConfigurationChanged and I get the error:

onConfigurationChanged型BaseActivity的(配置)必须覆盖或实现超类型的方法的方法

下面是我的BaseActivity.java:

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 that I can override this method... Any ideas?

推荐答案

你有 android.content.res.Configuration 在import语句? Eclipse可以,如果你preSS按Ctrl + Shift + O。

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.

这篇关于为什么我不能覆盖onConfigurationChanged?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆