0

在 Android 中,有一种非常标准的方法可以让您的系统类与它们的系统类交互:

@Override
public void onResume() {
    super.onResume ();
    //your code here
}

当您在 Eclipse 中键入“onr”然后控制空间时,存根会像这样填写,并在调用中使用 super 方法。您将如何表明您想从超类中执行此操作?

4

2 回答 2

1

There are two cases for calling a function in a subclass from the superclass:

  • When the superclass or one of its ancestors has declared the function that you want to call - simply call that function: the override is going to be called.
  • When the function is first introduced in a subclass - you need an explicit cast in your call. This option almost always indicates a problem in your design, and should be avoided.
于 2013-04-08T07:34:31.317 回答
0

when implementing subclassing, you can override any public or protected method, the default behavior of a overridden method in Eclipse is to do what the parent class does, therefor the automatic code for any method that's overriden is to call the parent via super.

于 2013-04-08T07:37:43.803 回答