D
D
Dinasars2020-02-16 17:09:59
Kotlin
Dinasars, 2020-02-16 17:09:59

How to run fragment fun from main activity?

I have a TabLayout, each tab has a fragment attached to it with its own markup.
Tell me how to run a function in a fragment from the main activity?
From the fragment, I launch the function of the main activity like this:
(activity as MainActivity).myFun()

Kotlin

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2020-02-16
@Dinasars

FragmentManager.findFragmentByTag/ById

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question