Fragment lifecycle - which method is called upon show / hide?

前端 未结 11 1036
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 08:31

I am using the following method to switch between Fragments (in my NavigationDrawer) by showing / hiding them.

protected void showFragment(int container, Fra         


        
11条回答
  •  臣服心动
    2020-12-04 09:06

    of course you can @Override the following method to do so:

    @Override
        public void setUserVisibleHint(boolean isVisibleToUser) {
            super.setUserVisibleHint(isVisibleToUser);
            if (isVisibleToUser) {
                // Do your Work
            } else {
                // Do your Work
            }
        }
    

提交回复
热议问题