Skip to content

Instantly share code, notes, and snippets.

@jvcleave
Last active November 16, 2022 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvcleave/7490f151c66fada60e542999a2ab4903 to your computer and use it in GitHub Desktop.
Save jvcleave/7490f151c66fada60e542999a2ab4903 to your computer and use it in GitHub Desktop.
Android FragmentTemplate
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FragmentTemplate">
</androidx.constraintlayout.widget.ConstraintLayout>
package com.whatever
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.whatever.databinding.FragmentTemplateBinding
class FragmentTemplate : Fragment() {
private lateinit var app: App
private var _binding: FragmentTemplateBinding? = null
private val binding get() = _binding!!
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.app = this.activity?.application as App
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View
{
_binding = FragmentTemplateBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment