Are you looking for an answer to the query “Given the fragment below, how would you get access to a TextView with an ID of text_home contained in the layout file of a Fragment class?”? If that’s the case, congratulations! You’ve arrived to the correct location. Throughout this post, I will assist you in answering your question correctly.
Given the fragment below, how would you get access to a TextView with an ID of text_home contained in the layout file of a Fragment class?
private lateinit var textView: TextView
override fun onCreateView(…): View? {
val root = inflator.inflator(R>layout.fragment_home, container, false)
textView = ??
return root
}
Options
- root.find(R.id.text_home)
- root.findViewById(R.id.text_home)
- root.getById(R.id.text_home)
- findViewByID(R.id.text_home)
The Correct Answer Is:
- root.findViewById(R.id.text_home)
Warming Up
I hope I was able to provide you with the correct answer to your question “Given the fragment below, how would you get access to a TextView with an ID of text_home contained in the layout file of a Fragment class?”. The above question was asked in the LinkedIn Android Skill Quiz Exam. I appreciate your trust in this website. Additionally please keep checking back to this site for more answers to questions from other certification exams.