Is There A Parent Class For Every Binding Class Using View Binding?
I am using ViewBinding and I am trying to reduce the code creating a Fragment that is an abstract class and contains this code: abstract class MyFragment : Fragment() {
Solution 1:
It should be ViewBinding
. The code snippet Should work for base fragment.
abstract class BaseFragment<V: ViewBinding> : Fragment(){
private var binding: V? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = getBinding()
return binding?.root
}
abstract fun getBinding(): V
}
Post a Comment for "Is There A Parent Class For Every Binding Class Using View Binding?"