I have 4 fragments. I switch among them by using hide
/show
transactions. One of them may have nested fragments which are added by replace
transaction. The issue is that if I add a nested fragment hide main fragment and show it again the onHiddenChanged
method of my nested fragment is not called. Why so? How can I determine when my nested fragment become visible?
Asked
Active
Viewed 2,990 times
6

Blo
- 11,903
- 5
- 45
- 99

Lingviston
- 5,479
- 5
- 35
- 67
2 Answers
4
I also came across the problem you are facing.
I found that hiding/showing a parent fragment had no effect on the child fragments' visible states, and wouldn't call onHiddenChanged()
and would return isVisible() = true
always.
See my answer in another question for my workaround.
Basically I created my own getIsVisible()
function on a BaseFragment
which recursively looks through any parents to find it's actual visible state. I am sure you could do something similar with onHiddenChanged()
by propagating it to all the child fragments.
I know this is old, but maybe someone could benefit from this knowledge :)
-4
For inner fragments, use getChildFragmentManager().

Abhishek Shukla
- 1,242
- 8
- 11
-
5And where is the answer here? – Lingviston Dec 10 '13 at 10:56