I have this neat function:
private void addMapFragment(){
if(!mapFragment.isAdded()){
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.mapContainer, mapFragment);
ft.commit();
}
}
I'm calling addMapFragment()
in my activity's onCreate()
. I then have a callback from a webrequest that calls addMapMapFragment()
. The isAdded()
method doesn't look useful at all since I'm getting a crash saying "Fragment already added: MapFragment[...]
"
Any clue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…