Android onResume 和 onCreate

标签 android android-activity

我有一个关于 Activity 生命周期逻辑的问题:

enter image description here

当我学习Android时,设置一个Activity总是在onCreate()函数中完成。现在,当我恢复我的 Activity 时,onResume() 中可能有一些事情要在 onCreate() 中完成。但是,为什么我们不把所有的东西都放到 onResume() 中呢?

最佳答案

why would we not just put all the stuff into onResume()?

onCreate() 会在您的 Activity 创建时调用,您需要初始化应用程序的一些非常重要的东西,例如您的主布局!

关于Android onResume 和 onCreate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34229247/

相关文章:

安卓 SetTextColor 错误 : Screen switching during mySQL call

java - 将字符串导出到电子邮件正文

android - 单击自定义 DialogPreference 按钮上的事件

android @Nullable注解

android - Google Developer Console 遵循的时区是什么?

java - 打开 Activity 期间应用程序崩溃

android - 如何从 Activity 的包含类启动 Intent

android - 如何在 Android Activity 中实现 'Remember me' 函数?

android - 使用 Mockito 进行 JVM 单元测试以测试网络请求的 Retrofit2 和 RxJava

android - ImageButton 更改 : the new image is plotted on top of original image