In my project I use three tab to show three activities in single screen.
Tab 1 - Map
Tab 2 - Games
Tab 3 - Imageflipper
When I select tabs in series like Map--->Ga
Use of this code in TopRatedfragment.java solve this problem:
private static View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent();
if (parent != null)
parent.removeView(view);
}
try {
view = inflater.inflate(R.layout.map, container, false);
} catch (InflateException e) {
/* map is already there, just return view as it is */
}
return view;
}
Caused by: java.lang.IllegalArgumentException: Binary XML file line #10: Duplicate id 0x7f050010, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
you are absolutely right about the error bieng the xml, but only because you are creating a new fragment that android is already holding on the stack.
instead of creating a new fragemtn you want to use a FragmentManager
FragmentManager fman=getFragmentManager();
fman.popBackStack();
itll be something along these lines.... for more exact code....
Fragment fragment = (Fragment) getFragmentManager().
.findFragmentById(R.your id here);
if (fragment != null && fragment.isInLayout()) {
fman.beginTransaction().show(fragment)
} else {
Fragment fragment = (Fragment) getFragmentManager().beginTransaction().add(your container-the file the error is coming from that holds all you fragments, fragment)
fman.beginTransaction().show(fragment)
}