Here's the code:
private lateinit var binding: ResultProfileBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ResultProfileBinding.**inflate(layoutInflater)**
val view = binding.root
setContentView(view)
}
Why layoutInflater? Isn't inflate supposed to inflate an xml file?
Doing a Ctr+Q on inflate gives this public static @NonNull com.example.ActivityMainBinding inflate(@NonNull android.view.LayoutInflater inflater)
I can't find this function on the android developer website. It's either in LayoutInflater or View. Where can you find this function?
Yes. A
LayoutInflaterinflates layout resources.It is code-generated in your project. That generated code is not significantly different than if you had typed it in yourself, which is why it uses a
LayoutInflaterto inflate the associated layout resource.On your computer. Specifically, it will be in one of the subdirectories off of your module's
build/directory.