如果文档/教程说至少它的方法 onCreate()
必须 是,为什么 android.app.Activity
不是设计抽象的实现的。
来自 http://developer.android.com/guide/components/activities.html
You must implement this method. The system calls this when creating your activity.
即使没有明确提及,如果没有实现,拥有 android.app.Activity
对象也没有意义,或者?我知道 parrent 可能需要在自己的 onCreate()
实现中执行代码,但是当父 onCreate()
的一部分调用抽象时肯定可以设计需要开发者实现的回调方法。
这种设计的例子:
public abstract class Activity {
public abstract void implementThis(Object o);
public void onCreate(Object o){
//Do stuff
implementThis(o);
//Do other stuff or end.
}
}
我是不是漏掉了什么?如果开发人员必须并且需要对其进行子类化并提供自定义实现,为什么会有非抽象的Activity
?
最佳答案
“此方法的默认实现执行任何先前已被 onSaveInstanceState(android.os.Bundle) 卡住的 View 状态的恢复。”
关于java - 为什么 android.app.Activity 在设计上不是抽象的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18260383/