超一流的android生命周期 [英] super class android life cycle
问题描述
为什么你需要调用父类在android的生命周期?例如,在的onCreate需要调用super.onCreate,或的onDestroy super.onDestroy
Why is it that you need to call the super class in the android lifecycle? For example, in onCreate you need to call super.onCreate, or onDestroy super.onDestroy.
推荐答案
这可以确保在整个类层次结构的任何有关生命周期管理code被调用。
It makes sure that any relevant lifecycle management code across the full class hierarchy gets invoked.
如果你有 MyBaseActivity
扩展活动
和 MySpecificActivity
扩展 MyBaseActivity
,通过调用在每个级别的手段生命周期方法在超 MyBaseActivity
将仍然能够响应生命周期事件。
If you have MyBaseActivity
that extends Activity
, and MySpecificActivity
that extends MyBaseActivity
, calling through to the lifecycle methods in the superclass at each level means MyBaseActivity
will still be able to respond to lifecycle events.
这篇关于超一流的android生命周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!