How to put Google Maps V2 on a Fragment using ViewPager

前端 未结 13 1976
攒了一身酷
攒了一身酷 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:35

    I've a workaround for NullPointerException when remove fragment in on DestoryView, Just put your code in onStop() not onDestoryView. It works fine!

    @Override
    public void onStop() {
        super.onStop();
        if (mMap != null) {
            MainActivity.fragmentManager.beginTransaction()
                    .remove(MainActivity.fragmentManager.findFragmentById(R.id.location_map)).commit();
            mMap = null;
        }
    }
    

提交回复
热议问题