kotlin fragment newinstance code example
Example: newinstance fragment kotlin
class NameOfFragment : Fragment() {
companion object {
// new instance pattern for fragment
@JvmStatic
fun newInstance(): NameOfFragment {
val nameOfFragment = NameOfFragment()
val args = Bundle()
nameOfFragment.arguments = args
return nameOfFragment
}
}
//Initial fragment
override fun getInitialFragment(): Fragment {
return NameOfFragment.newInstance()
}