43.5 Working with the Binding Class
The next step is to modify the code within the MainFragment.kt file to obtain a reference to the binding class instance. This is best achieved by rewriting the onCreateView() method:
.
.
import androidx.databinding.DataBindingUtil
import com.ebookfrenzy.viewmodeldemo.databinding.MainFragmentBinding
.
.
class MainFragment : Fragment() {
companion object {
fun newInstance() = MainFragment()
}
private lateinit var viewModel: MainViewModel
lateinit var binding: MainFragmentBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
...