Skip to content

Instantly share code, notes, and snippets.

@cribetti
Last active March 12, 2020 15:40
Show Gist options
  • Save cribetti/9166b3659942b8967167572a134ff1e5 to your computer and use it in GitHub Desktop.
Save cribetti/9166b3659942b8967167572a134ff1e5 to your computer and use it in GitHub Desktop.
class MyFragment : Fragment() {
private lateinit var arg: String
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.getString(ARG) ?: ""
}
companion object {
fun newInstance(arg: String) =
MyFragment().apply {
arguments = Bundle().apply {
putString(ARG, arg)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment