简体   繁体   English

Android Runtime中的onResume()错误

[英]onResume() in android runtime error

I am trying to call onResume so that I can reload variables after they are changed from another fragment after I return. 我试图调用onResume,以便在返回后从另一个片段中更改变量后重新加载变量。

@Override
    public void onResume(){
        check1=(CheckBox)getActivity().findViewById(R.id.CheckBox01);

    }

Attached above is my onResume() code. 上面的附件是我的onResume()代码。 CheckBox01 is in another fragment. CheckBox01在另一个片段中。 However, on runtime I get an error and the application quits. 但是,在运行时出现错误,应用程序退出。

It is complaining 它在抱怨

Unable to resume Activity: android.app.supernotcalledException: Fragment Tabmodes did not call through to super.Resume() 无法恢复活动:android.app.supernotdrawnException:片段Tabmodes没有调用到super.Resume()

Where is my error? 我的错误在哪里?

You must call the super method when you override onResume() , as the error (cryptically) states: 当您重写onResume() ,必须调用super方法,因为错误(隐式地指出):

@Override
public void onResume(){
    super.onResume();
    check1=(CheckBox)getActivity().findViewById(R.id.CheckBox01);
}

supernotcalledException and did not call through to super.Resume() are telling what's the error! supernotcalledExceptiondid not call through to super.Resume()告诉有什么错误!

You're missing the super.onResume(); 您错过了super.onResume(); call when overriding the onResume() method. 重写onResume()方法时调用。

The error is that you are required to call super.onResume. 错误是您需要调用super.onResume。 when overriding the initialize and teardown methods in android, you have to call the super version of the method or it won't work. 当在android中覆盖initialize和teardown方法时,您必须调用该方法的超级版本,否则它将无法正常工作。 super.onCreate, super.onResume, super.onDestroy, etc. i tend to start my init methods with the super call and end my teardown methods with it. 我倾向于用super调用开始我的init方法,并用super结束我的拆解方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM