I have a navigation drawer activity and fragments are used for different items of the navigation drawer as usual. There is a tab layout in first item of navigation drawer. Tab layout has been implemented using viewpager. There is a map inside this viewpager.
What I want to do is call
SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
But mapFragment is always null.
I spent more than 2 hours applying many methods but I couldn't succeed.
The problem here according to my knowledge is this. getActivity() method return the navigation drawer activity. getSupportFragmentManager() return the fragment attached to navigation drawer. But the map is not in that fragment. Map is inside the fragment within the view pager.
Can anyone suggest a method to achieve this?
use this getChildFragmentManager();
to get the FragmentManager
inside a Fragment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With