Last active
March 10, 2020 11:40
-
-
Save rcgonzalezf/b1755891115abe44a96e77d3587dd824 to your computer and use it in GitHub Desktop.
Fragment new Instance in Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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