Android的 - 这活动方法需要一个超级构造函数? [英] Android - which Activity methods require a super constructor?

查看:163
本文介绍了Android的 - 这活动方法需要一个超级构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数Android应用程序,的onCreate()被覆盖与code的第一位是 super.onCreate(savedInstanceState),我知道这合savedInstanceState和捆绑时,只需要编译但对于所有的构造函数?

In most Android apps, onCreate() is overridden with the first bit of code being super.onCreate(savedInstanceState) and I know this gathers the savedInstanceState Bundle and is neccessary for compilation but what about all of the constructors?

onResume()的onStop()的onStop()等。其中覆盖的方法有你需要包括重要的超级构造函数?

onResume(), onStop(), onStop() etc. Which overridden methods have important super constructors you need to include?

有一个名单的地方?

我看到包括在一些code超级构造函数,而不是别人。我有时包括他们自己,不是别人,从来没有真正注意到的差异。

I see the super constructors included in some code, not in others.. I have included them sometimes myself, others not and have never really noticed a difference..

这可以摆脱任何光线将深受好评!

Any light that could be shed would be well received!

干杯

推荐答案

的onCreate()在onStart() onResume()用于启动该活动,而在的onStop()的onDestroy( )用于停止或清理活动。

onCreate(), onStart() and onResume() are used to startup the activity while on onStop() and onDestroy() are used to stop or clean up the activity.

根据的文档,你需要调用超级每种方法。

As per the documentation you need to call the super for each of the method.

派生类必须通过打电话给超类的实现
  的这种方法。如果他们不这样做,一个会抛出异常。

Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

有关更多信息

这篇关于Android的 - 这活动方法需要一个超级构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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