I've read that it's important to call setContentView() early in an activity since it builds the view objects that may be manipulated by subsequent code in onCreate().
In terms of lifecycle, does the view get drawn to screen as soon as setContentView() is called, or does it allow the onCreate() function to build/populate the information in the view objects, and wait to actually draw it after onCreate() completes?
Thanks!
does the view get drawn to screen as soon as setContentView() is called
No.
or does it allow the onCreate() function to build/populate the information in the view objects, and wait to actually draw it after onCreate() completes?
Yes. The View
objects are created immediately as part of setContentView()
. However, all drawing operations (from onCreate()
or anywhere else) really result in messages being put on a message queue that the main application thread works through.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With