Getting Google Map Fragment in onCreateView using ActionBar tabs

前端 未结 1 998
我在风中等你
我在风中等你 2021-01-04 23:36

I\'m trying to retrieve the Google Map fragment while using Tabs in an ActionBar. When I load the tabbed page the map loads fine, but I want to get the map object so I can c

相关标签:
1条回答
  • 2021-01-05 00:02

    You can get reference to the fragment containing your Map using mViewPager.getItem(0) and then cast to Map fragment and use it any way you like. But this is actually not very good design to operate on fragment from the outside. So I would recommend you to implement all the business logic related to map inside Map fragment, this way you don't need to solve that kind of issue, that you posted and all you business logic is encapsulated inside a fragment, which is portable.

    0 讨论(0)
提交回复
热议问题