【发布时间】:2015-02-07 00:07:26
【问题描述】:
大家好,我想问一下如果我在 super.onDestroyView(); 之前写的东西有什么区别;在 super.onDestroyView(); 之后见下面的例子
在 super.ondestoryview() 之前移除片段;
@Override
public void onDestroyView() {
try {
Fragment fragment = (getFragmentManager()
.findFragmentById(R.id.mapviews));
FragmentTransaction ft = getActivity().getSupportFragmentManager()
.beginTransaction();
ft.remove(fragment);
ft.commit();
} catch (Exception e) {
e.printStackTrace();
}
super.onDestroyView();
}
在 super.ondestoryview() 之后移除片段;
@Override
public void onDestroyView() {
super.onDestroyView();
try {
Fragment fragment = (getFragmentManager()
.findFragmentById(R.id.mapviews));
FragmentTransaction ft = getActivity().getSupportFragmentManager()
.beginTransaction();
ft.remove(fragment);
ft.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
【问题讨论】:
-
如果我在 super.ondestroyview 之前和 super.ondestroyview 之后写这个方法会做什么
-
groups.google.com/forum/#!topic/android-developers/ndsrBsIchFc。阅读 dianne hackborn 的评论
-
感谢 Eli Rising 和 Raghunandan 的全力帮助