Skip to content

Instantly share code, notes, and snippets.

@mzaimilzam
Created March 29, 2021 15:39
Show Gist options
  • Save mzaimilzam/0c15300cc5f1477f8cf10ee7f489dead to your computer and use it in GitHub Desktop.
Save mzaimilzam/0c15300cc5f1477f8cf10ee7f489dead to your computer and use it in GitHub Desktop.
old way
package com.mzaiilzam.viewbindingdelegate
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.mzaiilzam.viewbindingdelegate.databinding.FragmentFirstBinding
class FirstFragment : Fragment() {
private var _binding: FragmentFirstBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
_binding = FragmentFirstBinding.inflate(inflater, container, false)
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment