48.9 Adding View Binding Support to the Destination Fragments
Since we will be accessing some of the views in the fragment layouts we will need to modify the current code to enable view binding support. Begin by editing the MainFragment.kt file and making the following changes:
.
.
import com.ebookfrenzy.navigationdemo.databinding.MainFragmentBinding
class MainFragment : Fragment() {
.
.
private var _binding: MainFragmentBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = MainFragmentBinding.inflate(inflater, container, false)
...