当应super.onResume()被调用? [英] When should super.onResume() be called?

查看:703
本文介绍了当应super.onResume()被调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应 super.onResume(); 被调用,上的第一行 onResume()或最后一行?

 保护无效onResume(){
    Log.i(MY_DEBUG_TAG,关于恢复);
    super.onResume();
    displayDashboard();
}
 

解决方案

无论你是否选择调用超级方法取决于是否需要继承的功能。你可以经常发现,如果你需要调用的API文档的超级方法。

有时候,你需要做一些超级方法被调用之前(即过滤属性或执行一个动作)。有时候你的code已发生超方法已经执行完毕。

这是非常多的具体实施。

When should super.onResume(); be called, on the first line of onResume() or on the last line?

protected void onResume() {
    Log.i(MY_DEBUG_TAG, "On Resume");
    super.onResume();
    displayDashboard();
}

解决方案

Whether or not you choose to call the super method depends upon whether you require the inherited functionality. You can often find out if you need to call the super method from Api documentation.

Sometimes you need to do something before the super method is called (ie filter an attribute or perform an action). Sometimes your code has to happen after the super method has executed.

It is very much implementation specific.

这篇关于当应super.onResume()被调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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