Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Created February 8, 2018 09:59
Show Gist options
  • Save EmmanuelGuther/b7c52e0ec57a52e775dad45e62d3764f to your computer and use it in GitHub Desktop.
Save EmmanuelGuther/b7c52e0ec57a52e775dad45e62d3764f to your computer and use it in GitHub Desktop.
communicate activity with fragment
fun sendToFragment(message: String) {
FooFragment.foo(message, fooFragmentInstance as FooFragment)
}
class FooFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
}
fun foo(message: String){
}
companion object {
fun foo(message: String, fooFragment: FooFragment){
fooFragment.fooFun(message)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment