New a fragment instance in Kotlin style.
Created
January 13, 2017 07:51
-
-
Save pokk/2ea715c6ae085b4328d52dfd77c6b800 to your computer and use it in GitHub Desktop.
using kotlin language in new instance.
This file contains hidden or 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
class MyFragment: BaseFragment() { | |
companion object Factory { | |
// The key name of the fragment initialization parameters. | |
private val ARG_PARAM_: String = "param_" | |
fun newInstance(arg1: String? = null): | |
MovieGalleryFragment = MovieGalleryFragment().apply { | |
this.arguments = Bundle().apply { | |
this.putString(ARG_PARAM_, arg1) | |
} | |
} | |
} | |
// Get the arguments from the bundle here. | |
private val arg: String by lazy { this.arguments.getString(ARG_PARAM_) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment