What is the difference between findViewById(R.id.content) and getRootView() ? Don’t both return the root view of an activity?
What is the difference between findViewById(R.id.content) and getRootView() ? Don’t both return the root
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.
The method
findViewById(R.id.content)searches down the view hierarchy for a View with the idcontent(it examines itself as well).The method
getRootView()walks up view hierarchy until it hits the root View (it examines itself as well).If the View you are in has the id
contentand it is the root view then these methods will give the same result, otherwise they won’t.