Elvir Ibrahimov Elvir Ibrahimov - 1 year ago 87
Android Question

How call method from Fragment in Activity?

I have a class MainActivity with three fragments.

Fragment Two uses a WebView.
I want to create a method

in Fragment Two
and call this method from MainActivity.
How can I do that?

Answer Source

With getActivity() you will get the activity instance, cast it to your activity name and call function from fragments. Assuming activity name as MainActivity

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download