I'm trying to get GoogleMap
object from a Fragment
, which is on the second page of ViewPager
, whose contents are given with FragmentPagerAdapter
.
My ViewPager
consist of two pages: an ordinary layout, and a Google map.
I can access to the first layout doing this:
View tempView = LayoutInflater.from(getApplication())
.inflate(R.layout.start_activity, null);
tempTextView = (TextView) tempView.findViewById(R.id.timer);
Everything is OK here. But I also want to access Google maps.
When the map was in a separate activity, I could get GoogleMap
object doing this:
map=((SupportMapFragment)getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
But now the above line returns null
The question is how to get GoogleMap
object from fragment now?
They suggest doing this (some people say this works), but it doesn't take effect for me:
map = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentByTag("android:switcher:" + R.id.pager + ":1")).getMap();
I'm providing the code here.