简体   繁体   中英

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.

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

    }

Attached above is my onResume() code. CheckBox01 is in another fragment. 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()

Where is my error?

You must call the super method when you override onResume() , as the error (cryptically) states:

@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!

You're missing the super.onResume(); call when overriding the onResume() method.

The error is that you are required to call 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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