I need to know when my fragment is visible, I was using setMenuVisibility but I now know it\'s not a good option. I\'m trying to implement setUserVisibleHint on a FragmentSt
setUserVisibleHint()
only works in a FragmentPagerAdapter. Please refer to Is Fragment.setUserVisibleHint() called by the android System?
setUserVisibleHint is available so that you have a way to tell the system the fragment is in fact not visible and not the other way around, when you are doing some fancy fragment transactions that specifically hide it. You can't use it to determine visibility and it defaults to true.
You should use the isVisible call to know if the fragment is visible and onAttach of the fragment or the root view classes to get callbacks when it's been attached to the activity or the respective root views.