Initialize views of activity in android -
is necessary initialize views
of activity
in oncreate()
only. can tell me best initializations of views
of activity
.
thanks
- no need initialize view if not modify it.
- you can initialize in activity lifecycle wish(before accessing).
- but is said best practice initialize in oncreate().
why:
if see lifecycle oncreate called when app page not shown. onstart called when app partially visible & onresume called when visible. so, want ready before seeing it. 1 reason.
another findviewbyid bit more expensive. so, don't want see when app visible.
onstart & onresume may call multiple time when go page. so, it's preferable initialize once , multiple time.
so, choice yours now.
Comments
Post a Comment