i\'m trying to use google maps v2 within viewpager (fragmentpager) in a fragment. It works fine if i swipe to fourth fragment (view pager), but if i go back to the first fragmen
public void onDestroyView() {
super.onDestroyView();
try {
Fragment fragment = (getFragmentManager().findFragmentById(R.id.map_container));
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.remove(fragment);
ft.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
This worked for me.
@Override
public void onDestroyView() {
// TODO Auto-generated method stub
super.onDestroyView();
try
{
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
ft.remove(mapFragment);
ft.commitAllowingStateLoss();
} catch (Exception e) {
e.printStackTrace();
}
}