[FIXED] Calling a Fragment method from a parent Activity


I see in the Android Fragments Dev Guide that an “activity can call methods in a fragment by acquiring a reference to the Fragment from FragmentManager, using findFragmentById() or findFragmentByTag().”

The example that follows shows how to get a fragment reference, but not how to call specific methods in the fragment.

Can anyone give an example of how to do this? I would like to call a specific method in a Fragment from the parent Activity. Thanks.


not get the question exactly as it is too simple :

ExampleFragment fragment = (ExampleFragment) getFragmentManager().findFragmentById(R.id.example_fragment);

Answered By – Dheeresh Singh

Answer Checked By – Mildred Charles (FixeMe Admin)

Leave a Reply

Your email address will not be published.