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?

Advertisement

private lateinit var textView: TextView
override fun onCreateView(…): View? {
val root = inflator.inflator(R>layout.fragment_home, container, false)
textView = ??
return root
}

  • root.getById(R.id.text_home)
  • findViewByID(R.id.text_home)
  • root.findViewById(R.id.text_home)
  • root.find(R.id.text_home)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top