Skip to content

Instantly share code, notes, and snippets.

@iwata-n
Created September 15, 2020 12:32
Show Gist options
  • Save iwata-n/e17f83466d996733d05d5245bc35933e to your computer and use it in GitHub Desktop.
Save iwata-n/e17f83466d996733d05d5245bc35933e to your computer and use it in GitHub Desktop.
androidxとDataBinding使った時のテンプレート
class TemplateFragment : Fragment(R.layout.template_fragment) {
companion object {
fun newInstance() = TemplateFragment()
}
private lateinit var viewModel: TemplateViewModel
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val binding = TemplateFragmentBinding.bind(view)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProviders.of(this).get(TemplateViewModel::class.java)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment