I need from one fragment to get access to the methods of another fragment.
How to do it?
I need from one fragment to get access to the methods of another fragment.
How to do it?
The abstract class FragmentManager manages fragments, it is logical that you can get a Fragment object. Everything is as usual - we cast findFragmentById() on the FragmentManager determine which fragment you need R.id.myFrag , R.id.myFrag fragment to the necessary type to get access (to determine the correct link of the object) to your public methods of the object. And then, as usual, myFrag.callMyMethod ().
Since the management is carried out by fragments from the Activity, it would be correct to define methods in the Activity, so that later they can be called from any other fragment. But you can make static methods, but this is a rake. This is how we call the activation method from the fragment:
Someactivity aa = (Someactivity)getContex(); aa.nameofmethod(); Source: https://ru.stackoverflow.com/questions/623200/
All Articles