我刚刚浏览了Android Developer Site,刷新了Activity Life周期,在每个代码示例中,超类方法旁边都有一条注释,"首先调用超类方法".
虽然这在创建半周期中有意义:onCreate,onStart和onResume,但我对于破坏半周期的正确程序有点困惑:onPause,onStop,onDestroy.
在破坏实例特定资源可能依赖的超类资源之前,首先销毁实例特定资源是有意义的,而不是反过来.但是注释建议不然.我错过了什么?
编辑:由于人们似乎对问题的意图感到困惑,我想知道的是以下哪一项是正确的?为什么?
1.Google建议
@Override
protected void onStop() {
super.onStop(); // Always call the superclass method first
//my implementation here
}
Run Code Online (Sandbox Code Playgroud)
另一种方式
@Override
protected void onStop() {
//my implementation here
super.onStop();
}
Run Code Online (Sandbox Code Playgroud) 我的页面有大约25个单选按钮组.当在组中选择单选按钮时,我想执行特定于该组的操作,因此需要无线电组的NAME属性.