为什么我要在没有代码的情况下调用 super
why should I call super when there is no code
当我调查 AppCompatActivity.java 以研究 API 时
我发现 onSupportActionModeStarted() 需要覆盖方法来调用 super.method()。即使没有代码。你有什么线索吗?
/**
* Notifies the Activity that a support action mode has been started.
* Activity subclasses overriding this method should call the superclass implementation.
*
* @param mode The new action mode.
*/
@Override
@CallSuper
public void onSupportActionModeStarted(@NonNull ActionMode mode) {
}
今天,AppCompatActivity
onSupportActionModeStarted()
没有。通过添加 @CallSuper
,Google 表示 "in the future, we might put code here, so please call through to the superclass implementation, so that your app does not break in the future"。
当我调查 AppCompatActivity.java 以研究 API 时 我发现 onSupportActionModeStarted() 需要覆盖方法来调用 super.method()。即使没有代码。你有什么线索吗?
/**
* Notifies the Activity that a support action mode has been started.
* Activity subclasses overriding this method should call the superclass implementation.
*
* @param mode The new action mode.
*/
@Override
@CallSuper
public void onSupportActionModeStarted(@NonNull ActionMode mode) {
}
今天,AppCompatActivity
onSupportActionModeStarted()
没有。通过添加 @CallSuper
,Google 表示 "in the future, we might put code here, so please call through to the superclass implementation, so that your app does not break in the future"。