Created
February 8, 2018 09:59
-
-
Save EmmanuelGuther/b7c52e0ec57a52e775dad45e62d3764f to your computer and use it in GitHub Desktop.
communicate activity with fragment
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
fun sendToFragment(message: String) { | |
FooFragment.foo(message, fooFragmentInstance as FooFragment) | |
} |
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 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