Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android setContentView operation

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!

like image 328
stormin986 Avatar asked Apr 24 '10 18:04

stormin986


1 Answers

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.

like image 87
CommonsWare Avatar answered Oct 01 '22 13:10

CommonsWare