android片段管理器中的Nullpointerexception
我有一个重新创建地图的代码,例如:android片段管理器中的Nullpointerexception,android,android-fragments,nullpointerexception,Android,Android Fragments,Nullpointerexception,我有一个重新创建地图的代码,例如: public void onDestroyView() { super.onDestroyView(); if (this.f != null && getFragmentManager().findFragmentById( this.f.getId()) != null) { Log.i("DE
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();
当我对代码进行注释时,没有问题
有人能帮我吗 使用相同的fragmentManager对象 公共无效onDestroyView(){ super.onDestroyView()
您正在使用两种类型的fragmentmanager为什么?我在这里使用了两种类型的fragmentmanager???MyFragmentManager支持和getFragmentManager()它不是两种类型的公共静态fragmentmanager MyFragmentManager支持;您可以添加一些代码吗?
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);
}
}