Skip to content

Instantly share code, notes, and snippets.

@mzaimilzam
Created March 29, 2021 15:46
Show Gist options
  • Save mzaimilzam/c3bfbea2f255065dd3acc90b3c6b0988 to your computer and use it in GitHub Desktop.
Save mzaimilzam/c3bfbea2f255065dd3acc90b3c6b0988 to your computer and use it in GitHub Desktop.
new way new 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 android.viewbinding.library.fragment.viewBinding
import com.mzaiilzam.viewbindingdelegate.databinding.FragmentFirstBinding
class FirstFragment : Fragment() {
// add this code
private val binding : FragmentFirstBinding by viewBinding()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_first, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.textView.text = "mzaimilzam"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment