Duplicate ID, tag null, or parent id with another fragment for com.google.android.gms.maps.MapFragment

前端 未结 23 1651
-上瘾入骨i
-上瘾入骨i 2020-11-22 00:25

I have an application with three tabs.

Each tab has its own layout .xml file. The main.xml has its own map fragment. It\'s the one that shows up when the application

23条回答
  •  星月不相逢
    2020-11-22 01:16

    I respect all the answers but i found this one liner solution: If n Is the Number of tabs then:

     mViewPager.setOffscreenPageLimit(n);
    

    Example: In case mentioned :

     mViewPager.setOffscreenPageLimit(2);
    

    View pager implements a queue so, you don't have to let it remove that fragment. onCreateView is called only once.

提交回复
热议问题