什么是Android的一个onCreate方法 [英] What is a OnCreate method in android

查看:130
本文介绍了什么是Android的一个onCreate方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void onCreate(Bundle savedInstanceState)
{
        super.onCreate(savedInstanceState);
        // load the layout
        setContentView(R.layout.filters); 
}

我的研究 ::

  • 的onCreate用于启动的活动
  • 超是用来调用父类的构造函数
  • 的setContentView用于设置的XML

不过,这是什么都在一起 -

But what is this all together -

  • 的onCreate(包savedInstanceState) ....为什么该软件包来 有,那是什么
  • 什么是 super.onCreate(savedInstanceState);
  • onCreate(Bundle savedInstanceState) .... why did that bundle come there, what is it
  • What is that super.onCreate(savedInstanceState);

在浅白一些解释将是有益

推荐答案

如果您保存在一个包(通​​常非持久性,在的onSaveInstanceState动态数据)的应用程序的状态,它可以被传递回的onCreate如果活动需要重新创建(例如,方向变化)。虽然方向变化,即从旋转横屏的设备的肖像和副花瓶活动重新创建并再次调用的onCreate,这样你就不能失去这个先验信息。如果没有数据提供,savedInstanceState为null。

If you save the state of the application in a bundle (typically non-persistent, dynamic data in onSaveInstanceState), it can be passed back to onCreate if the activity needs to be recreated (e.g., orientation change). While Orientation changes i.e rotating your device from landscape mode to portrait and vice-vase the activity recreate and call onCreate again, so that you don't lose this prior information. If no data was supplied, savedInstanceState is null.

有关更多信息,<一个href="http://developer.android.com/guide/topics/resources/runtime-changes.html">http://developer.android.com/guide/topics/resources/runtime-changes.html

这篇关于什么是Android的一个onCreate方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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