@AfterViews相当于的onCreate或onPostCreate? [英] @AfterViews is equivalent to onCreate or onPostCreate?

查看:1314
本文介绍了@AfterViews相当于的onCreate或onPostCreate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于Android的注释,

About Android Annotations,

@AfterViews相当于的onCreate或onPostCreate?

@AfterViews is equivalent to onCreate or onPostCreate?

或什么是注释相当于为每一个?

or what is the annotation equivalent for each one?

我可以删除的onCreate和onPostCreate的方法,并把我的两个全code在相同的方法@AfterViews?

can i remove "onCreate" and "onPostCreate" methods and put my whole code of both in the same method with @AfterViews?

推荐答案

在注释活动 s时, @AfterViews 注释的方法被称为的onCreate()。在注释片段 s时, @AfterViews 注释的方法称为 onViewCreated()。如果你不想做初始化创建视图之前,你可以安全地删除你的的onCreate()方法,并尽一切以 @AfterView 取值注解的方法。 然而 AfterViews 是得到一个机会给调用者初始化注入的观点,这是不是在的onCreate尚未有()

In annotated Activitys, the @AfterViews annotated methods are called in onCreate(). In annotated Fragments, the @AfterViews annotated methods are called in onViewCreated(). If you do not want to do initialization before views are created, you can safely remove your onCreate() method and do everything in an @AfterViews annotated method. However the main reason of AfterViews is getting a chance to the caller to initialise injected views, which are not yet available in onCreate().

这篇关于@AfterViews相当于的onCreate或onPostCreate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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