What event is triggered when a tab fragment is selected

前端 未结 3 618
孤城傲影
孤城傲影 2021-01-01 18:40

I\'m using tab fragments in an activity and the actionbar hosts the tabs. What I want to do is that whenever a fragment appears (or re-appears) in the view (selected by the

3条回答
  •  忘掉有多难
    2021-01-01 19:32

    You can override setUserVisibleHint(boolean isVisibleToUser) or onHiddenChanged (boolean hidden) method.

    • In case of setUserVisibleHint(boolean isVisibleToUser),
      isVisibleToUser=true when fragment is visible and isVisibleToUser=false when fragment is hidden.

    • In case of onHiddenChanged (boolean hidden), hidden:True if the
      fragment is now hidden, false if it is not visible.

提交回复
热议问题