How to determine when Fragment becomes visible in ViewPager

后端 未结 26 1323
心在旅途
心在旅途 2020-11-22 00:24

Problem: Fragment onResume() in ViewPager is fired before the fragment becomes actually visible.

For example, I have 2 fragments with

26条回答
  •  名媛妹妹
    2020-11-22 00:57

    Override Fragment.onHiddenChanged() for that.

    public void onHiddenChanged(boolean hidden)

    Called when the hidden state (as returned by isHidden()) of the fragment has changed. Fragments start out not hidden; this will be called whenever the fragment changes state from that.

    Parameters
    hidden - boolean: True if the fragment is now hidden, false if it is not visible.

提交回复
热议问题