newinstance fragment kotlin
snippet in kotlin

newinstance fragment kotlin

user4011

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()
}