0

I'm trying to do View Binding in Kotlin and fragments.

val button: Button = view.findViewById(R.id.Rutton)
button.setOnClickListener{
    //do something here.
}

but when it has many objects. I need to define that. So I had to look at:

Kotlin Android View Binding: findViewById vs Butterknife vs Kotlin Android Extension

and

Android developers documentation DataStore Overview: View Binding

but I can't find ResultProfileBinding in my Android Studio

What can I do in my program?

greybeard
  • 2,249
  • 8
  • 30
  • 66
張聖坤
  • 5
  • 2

1 Answers1

0

If you followed every instruction of the link you just posted, Specially the setup instructions, you should be able to import ResultProfileBinding.

Keep in mind that this ********Binding class will have the same name of the layout file. Per example, if your layout file is my_own_layout.xml the binding class will be MyOwnLayoutBinding. In this particular case they called their layout file result_profile.xml

  • @jortas_mr.json My Android Version is 4.1.1. I had already added ```buildFeatures { viewBinding true }```in my build grade(app), but I think it was not changed at my project settings. – 張聖坤 Dec 24 '20 at 01:52