Fragment's onResume() not called when popped from backstack

前端 未结 7 2016
梦谈多话
梦谈多话 2021-02-04 01:17

Hi I am developing android application in which I am using I am using single Activity and 3 fragments. So consider I have 3 fragments A B C. When I switch from A to

相关标签:
7条回答
  • 2021-02-04 02:14

    Put this code in your fragment.

    @Override
    public void setUserVisibleHint(boolean visible) {
            super.setUserVisibleHint(visible);
            if (visible && isResumed()) {
                onResume();
            }
        }
    
        @Override
        public void onResume() {
            super.onResume();
            if (!getUserVisibleHint()) {
                return;
            }
            setData();
        }
    
    0 讨论(0)
提交回复
热议问题