getFragmentManager()被弃用的代替方法
getFragmentManager()被弃用的代替方法
当需要管理activity或者fragment中的fragment时使用getChildFragmentManager()。
当需要本身需要与fragment关联的activity交互时使用getParentFragmentManager()。
以下为getParentFragment()方法的注释:
Return the FragmentManager for interacting with fragments associated with this fragment’s activity. Note that this will be available slightly before getActivity(), during the time from when the fragment is placed in a FragmentTransaction until it is committed and attached to its activity.
If this Fragment is a child of another Fragment, the FragmentManager returned here will be the parent’s getChildFragmentManager().
Throws:
IllegalStateException – if not associated with a transaction or host
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Hexo!
