2014-03-03 59 views
1

我有一个代码来重新创建地图,如:NullPointerException异常android系统碎片经理

public void onDestroyView() { 
     super.onDestroyView();  

     if (this.f != null 
       && getFragmentManager().findFragmentById(
         this.f.getId()) != null) { 
      Log.i("DESTROY VIEW MAP", "MAP!!!!!!!!!!!"+f); 
      myFragmentManagerSupport.beginTransaction().remove(this.f).commit(); 
      Log.i("DESTROY VIEW MAP 222222222222222", "MAP!!!!!!!!!!!"+f); 
      // this.f = null; 
      Log.i("DESTROY VIEW MAP 333333333333333333", "MAP!!!!!!!!!!!"+f); 
     } 

    } 

,但我有力闭合,当我去从本节后面。我在代码中有错误

myFragmentManagerSupport.beginTransaction().remove(this.f).commit(); 

当我评论代码时,没有问题。

任何人都可以帮助我吗?

+0

您正在使用两种类型的fragmentmanager为什么? – keshav

+0

我在哪里使用了两种类型的片段管理器? –

+0

myFragmentManagerSupport和getFragmentManager() – keshav

回答

0

使用相同的fragmentManager对象 public void onDestroyView(){ super.onDestroyView();

if (this.f != null 
      && myFragmentManagerSupport().findFragmentById(
        this.f.getId()) != null) { 
     Log.i("DESTROY VIEW MAP", "MAP!!!!!!!!!!!"+f); 
     myFragmentManagerSupport.beginTransaction().remove(this.f).commit(); 
     Log.i("DESTROY VIEW MAP 222222222222222", "MAP!!!!!!!!!!!"+f); 
     // this.f = null; 
     Log.i("DESTROY VIEW MAP 333333333333333333", "MAP!!!!!!!!!!!"+f); 
    } 

}