Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@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?

like image 217
Ninja Coding Avatar asked Nov 30 '25 03:11

Ninja Coding


1 Answers

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

like image 177
WonderCsabo Avatar answered Dec 02 '25 17:12

WonderCsabo