At which point are Android views created? When the activity starts? When the app is started? When a call to setContentView() is made? Or at some other point?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You mean when is it safe to get the objects of your view?
If you refer to Activities, in the
onCreatemethod, after you callsetContentView(...)you can start callingfindViewById(...)to refer to the objects of your view.In the case of Fragments, the view is created in the
onCreateView(...)method. You can refer to the view in theonActivityCreated(...)callback, this is called after the Activity has been created, so it is safe to refer to the view here.