android - getChildFragment()要在什么情况下使用?
黄舟
黄舟 2017-04-17 11:51:53
0
1
574

是谁的方法?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
刘奇

Ask and answer your own questions~, as an example
This method is a Fragment method, used to manage Fragment on Fragment;
When using, if you use the V4 package, you will encounter a no Activity error. This is because the v4 package does not reset the childFragmentManager. Override the onDetch method of the parent Fragment to solve the problem:

   public void onDetach() {
               super.onDetach();
               try {
                    Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager");
                    childFragmentManager.setAccessible(true);
                    childFragmentManager.set(this, null);
               } catch (NoSuchFieldException e) {
                    throw new RuntimeException(e);
               } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
               }
          }`

References:
http://www.tuicool.com/articles/2eM32a
http://stackoverflow.com/questions/15207305/getting-the-error-java -lang-illegalstateexception-activity-has-been-destroyed

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template