Skip to content

Instantly share code, notes, and snippets.

@rcgonzalezf
Last active March 10, 2020 11:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcgonzalezf/b1755891115abe44a96e77d3587dd824 to your computer and use it in GitHub Desktop.
Save rcgonzalezf/b1755891115abe44a96e77d3587dd824 to your computer and use it in GitHub Desktop.
Fragment new Instance in Kotlin
package org.rcgonzalezf.kotlin
import android.os.Bundle
import android.support.v4.app.Fragment
class ExampleFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// More logic here
}
companion object {
private val PARAM = "PARAM"
fun newInstance(param: Serializable): ExampleFragment {
val args: Bundle = Bundle()
args.putSerializable(PARAM, param)
val fragment = ExampleFragment()
fragment.arguments = args
return fragment
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment