I need develop next situation: i have main_screen.xml with TabHost, wich have two (or more) Tabs – each of them have as root element ViewPager.
ViewPager have two (or more) pages next sequence MainViewList->DetailView->MapView and go back MapView->DetailView->MainViewList (M->D->M)
There i have problem: on the first pass all works fine, but after again M->D->M it’s crashes with exception than Only One MapView can be inflated with MapActivity.
I check with debug that method destroyItem on ViewPagerAdapter works corects – it’s remove MapView from parentView (ViewPager).
Also then i go Map->D->M i remove from list of screens in ViewPagerAdapter prevscreen – so i can’t return to screen if slide to left (first screen, or DetailView after MapView,i can’t slide back to MapView – i need this logic works).
Also you can see this post MapView not being removed from ViewPager? with same problem.
So i have found next solution
ViewPager is part of any Activtiy, so i create activity next code
This code ((ViewPager) mpViewHolder.currentView.getParent()).removeView(mpViewHolder.currentView);
have one problem – it’s you always will work with same MapView instance.