Ninja Coding
Ninja Coding

Reputation: 1404

@AfterViews is equivalent to onCreate or onPostCreate?

About Android Annotations,

@AfterViews is equivalent to onCreate or onPostCreate?

or what is the annotation equivalent for each one?

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

Upvotes: 3

Views: 3944

Answers (1)

WonderCsabo
WonderCsabo

Reputation: 12207

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().

Upvotes: 6

Related Questions