How to put Google Maps V2 on a Fragment using ViewPager

前端 未结 13 2135
攒了一身酷
攒了一身酷 2020-11-22 04:56

I am trying to do a tab layout same in Play Store. I got to display the tab layout using a fragments and viewpager from androidhive. However, I can\'t implement google maps

13条回答
  •  执念已碎
    2020-11-22 05:50

    This is the Kotlin way:

    In fragment_map.xml you should have:

    
    
    

    In your MapFragment.kt you should have:

        private fun setupMap() {
            (childFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?)!!.getMapAsync(this)
        }
    

    Call setupMap() in onCreateView.

提交回复
热议问题