onResume() not called on ViewPager fragment when using custom Loader

后端 未结 2 2072
借酒劲吻你
借酒劲吻你 2021-02-06 12:22

Short version:

I have a fragment that maintains a ViewPager for displaying two other fragments, let\'s call them FragmentOne a

2条回答
  •  悲哀的现实
    2021-02-06 13:06

    It appears to be a bug in support library. The change below solves the issue.

    // FragmentOne.java
    
    @Override
    public void onResume() {
        super.onResume();
        Handler handler = getActivity().getWindow().getDecorView().getHandler();
        handler.post(new Runnable() {
            @Override public void run() {
                // initialize the loader here!
                getLoaderManager().initLoader(0, null, FragmentOne.this);
            }
        });
    }
    

提交回复
热议问题